Image encoding/decoding method and device for performing prof, and method for transmitting bitstream

ABSTRACT

An image encoding/decoding method and apparatus are provided. An image decoding method according to the present disclosure is performed by an image decoding apparatus. The image decoding method may comprise deriving a prediction sample of a current block based on motion information of the current block, determining whether prediction refinement with optical flow (PROF) applies to the current block, deriving, based on that the PROF applies to the current block, a difference motion vector for each sample position in the current block, deriving a gradient for each sample position in the current block, deriving a PROF offset based on the difference motion vector and the gradient, and deriving a refined prediction sample for the current block based on the PROF offset.

TECHNICAL FIELD

The present disclosure relates to an image encoding/decoding method andapparatus and a method of transmitting a bitstream, and, moreparticularly, to an image encoding/decoding method and apparatus forperforming prediction refinement with optical flow (PROF), and a methodof transmitting a bitstream generated by the image encodingmethod/apparatus of the present disclosure.

BACKGROUND ART

Recently, demand for high-resolution and high-quality images such ashigh definition (HD) images and ultra high definition (UHD) images isincreasing in various fields. As resolution and quality of image dataare improved, the amount of transmitted information or bits relativelyincreases as compared to existing image data. An increase in the amountof transmitted information or bits causes an increase in transmissioncost and storage cost.

Accordingly, there is a need for high-efficient image compressiontechnology for effectively transmitting, storing and reproducinginformation on high-resolution and high-quality images.

DISCLOSURE Technical Problem

An object of the present disclosure is to provide an imageencoding/decoding method and apparatus with improved encoding/decodingefficiency.

Another object of the present disclosure is to provide an imageencoding/decoding method and apparatus for performing a PROF offset.

Another object of the present disclosure is to provide an imageencoding/decoding method and apparatus for performing PROF.

Another object of the present disclosure is to provide a method oftransmitting a bitstream generated by an image encoding method orapparatus according to the present disclosure.

Another object of the present disclosure is to provide a recordingmedium storing a bitstream generated by an image encoding method orapparatus according to the present disclosure.

Another object of the present disclosure is to provide a recordingmedium storing a bitstream received, decoded and used to reconstruct animage by an image decoding apparatus according to the presentdisclosure.

The technical problems solved by the present disclosure are not limitedto the above technical problems and other technical problems which arenot described herein will become apparent to those skilled in the artfrom the following description.

Technical Solution

An image decoding method according to an aspect of the presentdisclosure may comprise deriving a prediction sample of a current blockbased on motion information of the current block, determining whetherprediction refinement with optical flow (PROF) applies to the currentblock, deriving, based on that the PROF applies to the current block, adifference motion vector for each sample position in the current block,deriving a gradient for each sample position in the current block,deriving a PROF offset based on the difference motion vector and thegradient, and deriving a refined prediction sample for the current blockbased on the PROF offset.

In the image decoding method according to the present disclosure, thederiving the difference motion vector may comprise rounding of thedifference motion vector, and the rounding of the difference motionvector may generate a rounded difference motion vector by right-shiftingthe difference motion vector by 8.

In the image decoding method according to the present disclosure, thederiving the difference motion vector may comprise clipping the roundeddifference motion vector in a predetermined range, and the predeterminedrange may be set based on a fixed value dmvLimit derived regardless of abit depth of the current block.

In the image decoding method according to the present disclosure, thepredetermined range may be specified by a minimum value and a maximumvalue derived based on dmvLimit, and an absolute value of the minimumvalue and an absolute value of the maximum value may be set to the samevalue.

In the image decoding method according to the present disclosure, theminimum value may be (−dmvLimit+1) and the maximum value is(dmvLimit−1).

In the image decoding method according to the present disclosure,dmvLimit may be (1<<5).

In the image decoding method according to the present disclosure, thederiving the gradient may comprise right-shifting a neighboringprediction sample value at each sample position in the current block bya first shift, and the first shift may be set to a fixed valueregardless of a bit depth of the current block.

In the image decoding method according to the present disclosure, thefirst shift may be 6.

In the image decoding method according to the present disclosure, a PROFoffset derived in the deriving the PROF offset may be clipped in apredetermined range.

In the image decoding method according to the present disclosure, thepredetermined range in which the PROF offset is clipped may be set basedon a value dILimit derived based on a bit depth of the current block.

In the image decoding method according to the present disclosure, thepredetermined range in which the PROF offset is clipped may be[−dILimit, dILimit−1].

In the image decoding method according to the present disclosure,dILimit may be (1<<max(13, Bitdepth+1)).

An image decoding apparatus according to another aspect of the presentdisclosure may comprise a memory and at least one processor. The atleast one processor may comprise derive a prediction sample of a currentblock based on motion information of the current block, determinewhether prediction refinement with optical flow (PROF) applies to thecurrent block, derive, based on that the PROF applies to the currentblock, a difference motion vector for each sample position in thecurrent block, derive a gradient for each sample position in the currentblock, derive a PROF offset based on the difference motion vector andthe gradient, and derive a refined prediction sample for the currentblock based on the PROF offset.

An image encoding method according to another aspect of the presentdisclosure may comprise deriving a prediction sample of a current blockbased on motion information of the current block, determining whetherprediction refinement with optical flow (PROF) applies to the currentblock, deriving, based on that the PROF applies to the current block, adifference motion vector for each sample position in the current block,deriving a gradient for each sample position in the current block,deriving a PROF offset based on the difference motion vector and thegradient, and deriving a refined prediction sample for the current blockbased on the PROF offset.

In addition, a computer-readable recording medium according to anotheraspect of the present disclosure may store the bitstream generated bythe image encoding apparatus or the image encoding method of the presentdisclosure.

The features briefly summarized above with respect to the presentdisclosure are merely exemplary aspects of the detailed descriptionbelow of the present disclosure, and do not limit the scope of thepresent disclosure.

Advantageous Effects

According to the present disclosure, it is possible to provide an imageencoding/decoding method and apparatus with improved encoding/decodingefficiency.

Also, according to the present disclosure, it is possible to provide animage encoding/decoding method and apparatus for deriving a PROF offset.

Also, according to the present disclosure, it is possible to provide animage encoding/decoding method and apparatus for performing PROF.

Also, according to the present disclosure, it is possible to provide amethod of transmitting a bitstream generated by an image encoding methodor apparatus according to the present disclosure.

Also, according to the present disclosure, it is possible to provide arecording medium storing a bitstream generated by an image encodingmethod or apparatus according to the present disclosure.

Also, according to the present disclosure, it is possible to provide arecording medium storing a bitstream received, decoded and used toreconstruct an image by an image decoding apparatus according to thepresent disclosure.

It will be appreciated by persons skilled in the art that that theeffects that can be achieved through the present disclosure are notlimited to what has been particularly described hereinabove and otheradvantages of the present disclosure will be more clearly understoodfrom the detailed description.

DESCRIPTION OF DRAWINGS

FIG. 1 is a view schematically illustrating a video coding system, towhich an embodiment of the present disclosure is applicable.

FIG. 2 is a view schematically illustrating an image encoding apparatus,to which an embodiment of the present disclosure is applicable.

FIG. 3 is a view schematically illustrating an image decoding apparatus,to which an embodiment of the present disclosure is applicable.

FIG. 4 is a flowchart illustrating an inter prediction based video/imageencoding method.

FIG. 5 is a view illustrating the configuration of an inter predictionunit 180 according to the present disclosure.

FIG. 6 is a flowchart illustrating an inter prediction based video/imagedecoding method.

FIG. 7 is a view illustrating the configuration of an inter predictionunit 260 according to the present disclosure.

FIG. 8 is a view illustrating neighboring blocks available as a spatialmerge candidate.

FIG. 9 is a view schematically illustrating a merge candidate listconstruction method according to an example of the present disclosure.

FIG. 10 is a view illustrating a candidate pair for redundancy checkperformed on a spatial candidate.

FIG. 11 is a view illustrating a method of scaling a motion vector of atemporal candidate.

FIG. 12 is a view illustrating a position where a temporal candidate isderived.

FIG. 13 is a view schematically illustrating a motion vector predictorcandidate list configuration method according to an example of thepresent disclosure.

FIG. 14 is a view illustrating a parameter model of an affine mode.

FIG. 15 is a view illustrating a method of generating an affine mergecandidate list.

FIG. 16 is a view illustrating a CPMV derived from a neighboring block.

FIG. 17 is a view illustrating neighboring blocks for deriving aconstructed affine merge candidate.

FIG. 18 is a view illustrating a method of generating an affine MVPcandidate list.

FIG. 19 is a view illustrating a neighboring block of a sub-block basedTMVP mode.

FIG. 20 is a view illustrating a method of deriving a motion vectorfield according to a sub-block based TMVP mode.

FIG. 21 is a view illustrating a CU extended to perform BDOF.

FIG. 22 is a view illustrating a relationship among Δv(i, j), v(i, j)and a subblock motion vector.

FIG. 23 is a view illustrating a process of deriving a prediction sampleof a current block by applying PROF.

FIG. 24 is a view illustrating an example of a PROF process according tothe present disclosure.

FIG. 25 is a view illustrating a refined PROF process according to anembodiment of the present disclosure.

FIG. 26 is a view illustrating a refined diffMv derivation processaccording to an embodiment of the present disclosure.

FIG. 27 is a view illustrating a refined PROF process according toanother embodiment of the present disclosure.

FIG. 28 is a view illustrating a refined PROF process according toanother embodiment of the present disclosure.

FIG. 29 is a view illustrating a refined PROF process according toanother embodiment of the present disclosure.

FIG. 30 is a view illustrating a refined diffMv derivation processaccording to another embodiment of the present disclosure.

FIG. 31 is a view illustrating a refined diffMv derivation processaccording to another embodiment of the present disclosure.

FIG. 32 is a view illustrating a refined diffMv derivation processaccording to another embodiment of the present disclosure.

FIG. 33 is a view illustrating a refined PROF process of performingclipping a PROF offset according to the present disclosure.

FIG. 34 is a view showing a content streaming system, to which anembodiment of the present disclosure is applicable.

MODE FOR INVENTION

Hereinafter, the embodiments of the present disclosure will be describedin detail with reference to the accompanying drawings so as to be easilyimplemented by those skilled in the art. However, the present disclosuremay be implemented in various different forms, and is not limited to theembodiments described herein.

In describing the present disclosure, if it is determined that thedetailed description of a related known function or construction rendersthe scope of the present disclosure unnecessarily ambiguous, thedetailed description thereof will be omitted. In the drawings, parts notrelated to the description of the present disclosure are omitted, andsimilar reference numerals are attached to similar parts.

In the present disclosure, when a component is “connected”, “coupled” or“linked” to another component, it may include not only a directconnection relationship but also an indirect connection relationship inwhich an intervening component is present. In addition, when a component“includes” or “has” other components, it means that other components maybe further included, rather than excluding other components unlessotherwise stated.

In the present disclosure, the terms first, second, etc. may be usedonly for the purpose of distinguishing one component from othercomponents, and do not limit the order or importance of the componentsunless otherwise stated. Accordingly, within the scope of the presentdisclosure, a first component in one embodiment may be referred to as asecond component in another embodiment, and similarly, a secondcomponent in one embodiment may be referred to as a first component inanother embodiment.

In the present disclosure, components that are distinguished from eachother are intended to clearly describe each feature, and do not meanthat the components are necessarily separated. That is, a plurality ofcomponents may be integrated and implemented in one hardware or softwareunit, or one component may be distributed and implemented in a pluralityof hardware or software units. Therefore, even if not stated otherwise,such embodiments in which the components are integrated or the componentis distributed are also included in the scope of the present disclosure.

In the present disclosure, the components described in variousembodiments do not necessarily mean essential components, and somecomponents may be optional components. Accordingly, an embodimentconsisting of a subset of components described in an embodiment is alsoincluded in the scope of the present disclosure. In addition,embodiments including other components in addition to componentsdescribed in the various embodiments are included in the scope of thepresent disclosure.

The present disclosure relates to encoding and decoding of an image, andterms used in the present disclosure may have a general meaning commonlyused in the technical field, to which the present disclosure belongs,unless newly defined in the present disclosure.

In the present disclosure, a “picture” generally refers to a unitrepresenting one image in a specific time period, and a slice/tile is acoding unit constituting a part of a picture, and one picture may becomposed of one or more slices/tiles. In addition, a slice/tile mayinclude one or more coding tree units (CTUs).

In the present disclosure, a “pixel” or a “pel” may mean a smallest unitconstituting one picture (or image). In addition, “sample” may be usedas a term corresponding to a pixel. A sample may generally represent apixel or a value of a pixel, and may represent only a pixel/pixel valueof a luma component or only a pixel/pixel value of a chroma component.

In the present disclosure, a “unit” may represent a basic unit of imageprocessing. The unit may include at least one of a specific region ofthe picture and information related to the region. The unit may be usedinterchangeably with terms such as “sample array”, “block” or “area” insome cases. In a general case, an M×N block may include samples (orsample arrays) or a set (or array) of transform coefficients of Mcolumns and N rows.

In the present disclosure, “current block” may mean one of “currentcoding block”, “current coding unit”, “coding target block”, “decodingtarget block” or “processing target block”. When prediction isperformed, “current block” may mean “current prediction block” or“prediction target block”. When transform (inversetransform)/quantization (dequantization) is performed, “current block”may mean “current transform block” or “transform target block”. Whenfiltering is performed, “current block” may mean “filtering targetblock”.

In the present disclosure, the term “/” and “,” should be interpreted toindicate “and/or.” For instance, the expression “A/B” and “A, B” maymean “A and/or B.” Further, “A/B/C” and “A/B/C” may mean “at least oneof A, B, and/or C.”

In the present disclosure, the term “or” should be interpreted toindicate “and/or.” For instance, the expression “A or B” may comprise 1)only “A”, 2) only “B”, and/or 3) both “A and B”. In other words, in thepresent disclosure, the term “or” should be interpreted to indicate“additionally or alternatively.”

Overview of Video Coding System

FIG. 1 is a view showing a video coding system according to the presentdisclosure.

The video coding system according to an embodiment may include aencoding apparatus 10 and a decoding apparatus 20. The encodingapparatus 10 may deliver encoded video and/or image information or datato the decoding apparatus 20 in the form of a file or streaming via adigital storage medium or network.

The encoding apparatus 10 according to an embodiment may include a videosource generator 11, an encoding unit 12 and a transmitter 13. Thedecoding apparatus 20 according to an embodiment may include a receiver21, a decoding unit 22 and a renderer 23. The encoding unit 12 may becalled a video/image encoding unit, and the decoding unit 22 may becalled a video/image decoding unit. The transmitter 13 may be includedin the encoding unit 12. The receiver 21 may be included in the decodingunit 22. The renderer 23 may include a display and the display may beconfigured as a separate device or an external component.

The video source generator 11 may acquire a video/image through aprocess of capturing, synthesizing or generating the video/image. Thevideo source generator 11 may include a video/image capture deviceand/or a video/image generating device. The video/image capture devicemay include, for example, one or more cameras, video/image archivesincluding previously captured video/images, and the like. Thevideo/image generating device may include, for example, computers,tablets and smartphones, and may (electronically) generate video/images.For example, a virtual video/image may be generated through a computeror the like. In this case, the video/image capturing process may bereplaced by a process of generating related data.

The encoding unit 12 may encode an input video/image. The encoding unit12 may perform a series of procedures such as prediction, transform, andquantization for compression and coding efficiency. The encoding unit 12may output encoded data (encoded video/image information) in the form ofa bitstream.

The transmitter 13 may transmit the encoded video/image information ordata output in the form of a bitstream to the receiver 21 of thedecoding apparatus 20 through a digital storage medium or a network inthe form of a file or streaming. The digital storage medium may includevarious storage mediums such as USB, SD, CD, DVD, Blu-ray, HDD, SSD, andthe like. The transmitter 13 may include an element for generating amedia file through a predetermined file format and may include anelement for transmission through a broadcast/communication network. Thereceiver 21 may extract/receive the bitstream from the storage medium ornetwork and transmit the bitstream to the decoding unit 22.

The decoding unit 22 may decode the video/image by performing a seriesof procedures such as dequantization, inverse transform, and predictioncorresponding to the operation of the encoding unit 12.

The renderer 23 may render the decoded video/image. The renderedvideo/image may be displayed through the display.

Overview of Image Encoding Apparatus

FIG. 2 is a view schematically showing an image encoding apparatus, towhich an embodiment of the present disclosure is applicable.

As shown in FIG. 2 , the image encoding apparatus 100 may include animage partitioner 110, a subtractor 115, a transformer 120, a quantizer130, a dequantizer 140, an inverse transformer 150, an adder 155, afilter 160, a memory 170, an inter prediction unit 180, an intraprediction unit 185 and an entropy encoder 190. The inter predictionunit 180 and the intra prediction unit 185 may be collectively referredto as a “prediction unit”. The transformer 120, the quantizer 130, thedequantizer 140 and the inverse transformer 150 may be included in aresidual processor. The residual processor may further include thesubtractor 115.

All or at least some of the plurality of components configuring theimage encoding apparatus 100 may be configured by one hardware component(e.g., an encoder or a processor) in some embodiments. In addition, thememory 170 may include a decoded picture buffer (DPB) and may beconfigured by a digital storage medium.

The image partitioner 110 may partition an input image (or a picture ora frame) input to the image encoding apparatus 100 into one or moreprocessing units. For example, the processing unit may be called acoding unit (CU). The coding unit may be acquired by recursivelypartitioning a coding tree unit (CTU) or a largest coding unit (LCU)according to a quad-tree binary-tree ternary-tree (QT/BT/TT) structure.For example, one coding unit may be partitioned into a plurality ofcoding units of a deeper depth based on a quad tree structure, a binarytree structure, and/or a ternary structure. For partitioning of thecoding unit, a quad tree structure may be applied first and the binarytree structure and/or ternary structure may be applied later. The codingprocedure according to the present disclosure may be performed based onthe final coding unit that is no longer partitioned. The largest codingunit may be used as the final coding unit or the coding unit of deeperdepth acquired by partitioning the largest coding unit may be used asthe final coding unit. Here, the coding procedure may include aprocedure of prediction, transform, and reconstruction, which will bedescribed later. As another example, the processing unit of the codingprocedure may be a prediction unit (PU) or a transform unit (TU). Theprediction unit and the transform unit may be split or partitioned fromthe final coding unit. The prediction unit may be a unit of sampleprediction, and the transform unit may be a unit for deriving atransform coefficient and/or a unit for deriving a residual signal fromthe transform coefficient.

The prediction unit (the inter prediction unit 180 or the intraprediction unit 185) may perform prediction on a block to be processed(current block) and generate a predicted block including predictionsamples for the current block. The prediction unit may determine whetherintra prediction or inter prediction is applied on a current block or CUbasis. The prediction unit may generate various information related toprediction of the current block and transmit the generated informationto the entropy encoder 190. The information on the prediction may beencoded in the entropy encoder 190 and output in the form of abitstream.

The intra prediction unit 185 may predict the current block by referringto the samples in the current picture. The referred samples may belocated in the neighborhood of the current block or may be located apartaccording to the intra prediction mode and/or the intra predictiontechnique. The intra prediction modes may include a plurality ofnon-directional modes and a plurality of directional modes. Thenon-directional mode may include, for example, a DC mode and a planarmode. The directional mode may include, for example, 33 directionalprediction modes or 65 directional prediction modes according to thedegree of detail of the prediction direction. However, this is merely anexample, more or less directional prediction modes may be used dependingon a setting. The intra prediction unit 185 may determine the predictionmode applied to the current block by using a prediction mode applied toa neighboring block.

The inter prediction unit 180 may derive a predicted block for thecurrent block based on a reference block (reference sample array)specified by a motion vector on a reference picture. In this case, inorder to reduce the amount of motion information transmitted in theinter prediction mode, the motion information may be predicted in unitsof blocks, subblocks, or samples based on correlation of motioninformation between the neighboring block and the current block. Themotion information may include a motion vector and a reference pictureindex. The motion information may further include inter predictiondirection (L0 prediction, L1 prediction, Bi-prediction, etc.)information. In the case of inter prediction, the neighboring block mayinclude a spatial neighboring block present in the current picture and atemporal neighboring block present in the reference picture. Thereference picture including the reference block and the referencepicture including the temporal neighboring block may be the same ordifferent. The temporal neighboring block may be called a collocatedreference block, a co-located CU (colCU), and the like. The referencepicture including the temporal neighboring block may be called acollocated picture (colPic). For example, the inter prediction unit 180may configure a motion information candidate list based on neighboringblocks and generate information indicating which candidate is used toderive a motion vector and/or a reference picture index of the currentblock. Inter prediction may be performed based on various predictionmodes. For example, in the case of a skip mode and a merge mode, theinter prediction unit 180 may use motion information of the neighboringblock as motion information of the current block. In the case of theskip mode, unlike the merge mode, the residual signal may not betransmitted. In the case of the motion vector prediction (MVP) mode, themotion vector of the neighboring block may be used as a motion vectorpredictor, and the motion vector of the current block may be signaled byencoding a motion vector difference and an indicator for a motion vectorpredictor. The motion vector difference may mean a difference betweenthe motion vector of the current block and the motion vector predictor.

The prediction unit may generate a prediction signal based on variousprediction methods and prediction techniques described below. Forexample, the prediction unit may not only apply intra prediction orinter prediction but also simultaneously apply both intra prediction andinter prediction, in order to predict the current block. A predictionmethod of simultaneously applying both intra prediction and interprediction for prediction of the current block may be called combinedinter and intra prediction (CIIP). In addition, the prediction unit mayperform intra block copy (IBC) for prediction of the current block.Intra block copy may be used for content image/video coding of a game orthe like, for example, screen content coding (SCC). IBC is a method ofpredicting a current picture using a previously reconstructed referenceblock in the current picture at a location apart from the current blockby a predetermined distance. When IBC is applied, the location of thereference block in the current picture may be encoded as a vector (blockvector) corresponding to the predetermined distance.

The prediction signal generated by the prediction unit may be used togenerate a reconstructed signal or to generate a residual signal. Thesubtractor 115 may generate a residual signal (residual block orresidual sample array) by subtracting the prediction signal (predictedblock or prediction sample array) output from the prediction unit fromthe input image signal (original block or original sample array). Thegenerated residual signal may be transmitted to the transformer 120.

The transformer 120 may generate transform coefficients by applying atransform technique to the residual signal. For example, the transformtechnique may include at least one of a discrete cosine transform (DCT),a discrete sine transform (DST), a karhunen-loève transform (KLT), agraph-based transform (GBT), or a conditionally non-linear transform(CNT). Here, the GBT means transform obtained from a graph whenrelationship information between pixels is represented by the graph. TheCNT refers to transform acquired based on a prediction signal generatedusing all previously reconstructed pixels. In addition, the transformprocess may be applied to square pixel blocks having the same size ormay be applied to blocks having a variable size rather than square.

The quantizer 130 may quantize the transform coefficients and transmitthem to the entropy encoder 190. The entropy encoder 190 may encode thequantized signal (information on the quantized transform coefficients)and output a bitstream. The information on the quantized transformcoefficients may be referred to as residual information. The quantizer130 may rearrange quantized transform coefficients in a block form intoa one-dimensional vector form based on a coefficient scanning order andgenerate information on the quantized transform coefficients based onthe quantized transform coefficients in the one-dimensional vector form.

The entropy encoder 190 may perform various encoding methods such as,for example, exponential Golomb, context-adaptive variable length coding(CAVLC), context-adaptive binary arithmetic coding (CABAC), and thelike. The entropy encoder 190 may encode information necessary forvideo/image reconstruction other than quantized transform coefficients(e.g., values of syntax elements, etc.) together or separately. Encodedinformation (e.g., encoded video/image information) may be transmittedor stored in units of network abstraction layers (NALs) in the form of abitstream. The video/image information may further include informationon various parameter sets such as an adaptation parameter set (APS), apicture parameter set (PPS), a sequence parameter set (SPS), or a videoparameter set (VPS). In addition, the video/image information mayfurther include general constraint information. The signaledinformation, transmitted information and/or syntax elements described inthe present disclosure may be encoded through the above-describedencoding procedure and included in the bitstream.

The bitstream may be transmitted over a network or may be stored in adigital storage medium. The network may include a broadcasting networkand/or a communication network, and the digital storage medium mayinclude various storage media such as USB, SD, CD, DVD, Blu-ray, HDD,SSD, and the like. A transmitter (not shown) transmitting a signaloutput from the entropy encoder 190 and/or a storage unit (not shown)storing the signal may be included as internal/external element of theimage encoding apparatus 100. Alternatively, the transmitter may beprovided as the component of the entropy encoder 190.

The quantized transform coefficients output from the quantizer 130 maybe used to generate a residual signal. For example, the residual signal(residual block or residual samples) may be reconstructed by applyingdequantization and inverse transform to the quantized transformcoefficients through the dequantizer 140 and the inverse transformer150.

The adder 155 adds the reconstructed residual signal to the predictionsignal output from the inter prediction unit 180 or the intra predictionunit 185 to generate a reconstructed signal (reconstructed picture,reconstructed block, reconstructed sample array). If there is noresidual for the block to be processed, such as a case where the skipmode is applied, the predicted block may be used as the reconstructedblock. The adder 155 may be called a reconstructor or a reconstructedblock generator. The generated reconstructed signal may be used forintra prediction of a next block to be processed in the current pictureand may be used for inter prediction of a next picture through filteringas described below.

Meanwhile, as described below, luma mapping with chroma scaling (LMCS)is applicable in a picture encoding process.

The filter 160 may improve subjective/objective image quality byapplying filtering to the reconstructed signal. For example, the filter160 may generate a modified reconstructed picture by applying variousfiltering methods to the reconstructed picture and store the modifiedreconstructed picture in the memory 170, specifically, a DPB of thememory 170. The various filtering methods may include, for example,deblocking filtering, a sample adaptive offset, an adaptive loop filter,a bilateral filter, and the like. The filter 160 may generate variousinformation related to filtering and transmit the generated informationto the entropy encoder 190 as described later in the description of eachfiltering method. The information related to filtering may be encoded bythe entropy encoder 190 and output in the form of a bitstream.

The modified reconstructed picture transmitted to the memory 170 may beused as the reference picture in the inter prediction unit 180. Wheninter prediction is applied through the image encoding apparatus 100,prediction mismatch between the image encoding apparatus 100 and theimage decoding apparatus may be avoided and encoding efficiency may beimproved.

The DPB of the memory 170 may store the modified reconstructed picturefor use as a reference picture in the inter prediction unit 180. Thememory 170 may store the motion information of the block from which themotion information in the current picture is derived (or encoded) and/orthe motion information of the blocks in the picture that have alreadybeen reconstructed. The stored motion information may be transmitted tothe inter prediction unit 180 and used as the motion information of thespatial neighboring block or the motion information of the temporalneighboring block. The memory 170 may store reconstructed samples ofreconstructed blocks in the current picture and may transfer thereconstructed samples to the intra prediction unit 185.

Overview of Image Decoding Apparatus

FIG. 3 is a view schematically showing an image decoding apparatus, towhich an embodiment of the present disclosure is applicable.

As shown in FIG. 3 , the image decoding apparatus 200 may include anentropy decoder 210, a dequantizer 220, an inverse transformer 230, anadder 235, a filter 240, a memory 250, an inter prediction unit 260 andan intra prediction unit 265. The inter prediction unit 260 and theintra prediction unit 265 may be collectively referred to as a“prediction unit”. The dequantizer 220 and the inverse transformer 230may be included in a residual processor.

All or at least some of a plurality of components configuring the imagedecoding apparatus 200 may be configured by a hardware component (e.g.,a decoder or a processor) according to an embodiment. In addition, thememory 250 may include a decoded picture buffer (DPB) or may beconfigured by a digital storage medium.

The image decoding apparatus 200, which has received a bitstreamincluding video/image information, may reconstruct an image byperforming a process corresponding to a process performed by the imageencoding apparatus 100 of FIG. 2 . For example, the image decodingapparatus 200 may perform decoding using a processing unit applied inthe image encoding apparatus. Thus, the processing unit of decoding maybe a coding unit, for example. The coding unit may be acquired bypartitioning a coding tree unit or a largest coding unit. Thereconstructed image signal decoded and output through the image decodingapparatus 200 may be reproduced through a reproducing apparatus (notshown).

The image decoding apparatus 200 may receive a signal output from theimage encoding apparatus of FIG. 2 in the form of a bitstream. Thereceived signal may be decoded through the entropy decoder 210. Forexample, the entropy decoder 210 may parse the bitstream to deriveinformation (e.g., video/image information) necessary for imagereconstruction (or picture reconstruction). The video/image informationmay further include information on various parameter sets such as anadaptation parameter set (APS), a picture parameter set (PPS), asequence parameter set (SPS), or a video parameter set (VPS). Inaddition, the video/image information may further include generalconstraint information. The image decoding apparatus may further decodepicture based on the information on the parameter set and/or the generalconstraint information. Signaled/received information and/or syntaxelements described in the present disclosure may be decoded through thedecoding procedure and obtained from the bitstream. For example, theentropy decoder 210 decodes the information in the bitstream based on acoding method such as exponential Golomb coding, CAVLC, or CABAC, andoutput values of syntax elements required for image reconstruction andquantized values of transform coefficients for residual. Morespecifically, the CABAC entropy decoding method may receive a bincorresponding to each syntax element in the bitstream, determine acontext model using a decoding target syntax element information,decoding information of a neighboring block and a decoding target blockor information of a symbol/bin decoded in a previous stage, and performarithmetic decoding on the bin by predicting a probability of occurrenceof a bin according to the determined context model, and generate asymbol corresponding to the value of each syntax element. In this case,the CABAC entropy decoding method may update the context model by usingthe information of the decoded symbol/bin for a context model of a nextsymbol/bin after determining the context model. The information relatedto the prediction among the information decoded by the entropy decoder210 may be provided to the prediction unit (the inter prediction unit260 and the intra prediction unit 265), and the residual value on whichthe entropy decoding was performed in the entropy decoder 210, that is,the quantized transform coefficients and related parameter information,may be input to the dequantizer 220. In addition, information onfiltering among information decoded by the entropy decoder 210 may beprovided to the filter 240. Meanwhile, a receiver (not shown) forreceiving a signal output from the image encoding apparatus may befurther configured as an internal/external element of the image decodingapparatus 200, or the receiver may be a component of the entropy decoder210.

Meanwhile, the image decoding apparatus according to the presentdisclosure may be referred to as a video/image/picture decodingapparatus. The image decoding apparatus may be classified into aninformation decoder (video/image/picture information decoder) and asample decoder (video/image/picture sample decoder). The informationdecoder may include the entropy decoder 210. The sample decoder mayinclude at least one of the dequantizer 220, the inverse transformer230, the adder 235, the filter 240, the memory 250, the inter predictionunit 260 or the intra prediction unit 265.

The dequantizer 220 may dequantize the quantized transform coefficientsand output the transform coefficients. The dequantizer 220 may rearrangethe quantized transform coefficients in the form of a two-dimensionalblock. In this case, the rearrangement may be performed based on thecoefficient scanning order performed in the image encoding apparatus.The dequantizer 220 may perform dequantization on the quantizedtransform coefficients by using a quantization parameter (e.g.,quantization step size information) and obtain transform coefficients.

The inverse transformer 230 may inversely transform the transformcoefficients to obtain a residual signal (residual block, residualsample array).

The prediction unit may perform prediction on the current block andgenerate a predicted block including prediction samples for the currentblock. The prediction unit may determine whether intra prediction orinter prediction is applied to the current block based on theinformation on the prediction output from the entropy decoder 210 andmay determine a specific intra/inter prediction mode (predictiontechnique).

It is the same as described in the prediction unit of the image encodingapparatus 100 that the prediction unit may generate the predictionsignal based on various prediction methods (techniques) which will bedescribed later.

The intra prediction unit 265 may predict the current block by referringto the samples in the current picture. The description of the intraprediction unit 185 is equally applied to the intra prediction unit 265.

The inter prediction unit 260 may derive a predicted block for thecurrent block based on a reference block (reference sample array)specified by a motion vector on a reference picture. In this case, inorder to reduce the amount of motion information transmitted in theinter prediction mode, motion information may be predicted in units ofblocks, subblocks, or samples based on correlation of motion informationbetween the neighboring block and the current block. The motioninformation may include a motion vector and a reference picture index.The motion information may further include inter prediction direction(L0 prediction, L1 prediction, Bi-prediction, etc.) information. In thecase of inter prediction, the neighboring block may include a spatialneighboring block present in the current picture and a temporalneighboring block present in the reference picture. For example, theinter prediction unit 260 may configure a motion information candidatelist based on neighboring blocks and derive a motion vector of thecurrent block and/or a reference picture index based on the receivedcandidate selection information. Inter prediction may be performed basedon various prediction modes, and the information on the prediction mayinclude information indicating a mode of inter prediction for thecurrent block.

The adder 235 may generate a reconstructed signal (reconstructedpicture, reconstructed block, reconstructed sample array) by adding theobtained residual signal to the prediction signal (predicted block,predicted sample array) output from the prediction unit (including theinter prediction unit 260 and/or the intra prediction unit 265). Thedescription of the adder 155 is equally applicable to the adder 235.

Meanwhile, as described below, luma mapping with chroma scaling (LMCS)is applicable in a picture decoding process.

The filter 240 may improve subjective/objective image quality byapplying filtering to the reconstructed signal. For example, the filter240 may generate a modified reconstructed picture by applying variousfiltering methods to the reconstructed picture and store the modifiedreconstructed picture in the memory 250, specifically, a DPB of thememory 250. The various filtering methods may include, for example,deblocking filtering, a sample adaptive offset, an adaptive loop filter,a bilateral filter, and the like.

The (modified) reconstructed picture stored in the DPB of the memory 250may be used as a reference picture in the inter prediction unit 260. Thememory 250 may store the motion information of the block from which themotion information in the current picture is derived (or decoded) and/orthe motion information of the blocks in the picture that have alreadybeen reconstructed. The stored motion information may be transmitted tothe inter prediction unit 260 so as to be utilized as the motioninformation of the spatial neighboring block or the motion informationof the temporal neighboring block. The memory 250 may storereconstructed samples of reconstructed blocks in the current picture andtransfer the reconstructed samples to the intra prediction unit 265.

In the present disclosure, the embodiments described in the filter 160,the inter prediction unit 180, and the intra prediction unit 185 of theimage encoding apparatus 100 may be equally or correspondingly appliedto the filter 240, the inter prediction unit 260, and the intraprediction unit 265 of the image decoding apparatus 200.

Overview of Inter Prediction

An image encoding apparatus/image decoding apparatus may perform interprediction in units of blocks to derive a prediction sample. Interprediction may mean prediction derived in a manner that is dependent ondata elements of picture(s) other than a current picture. When interprediction applies to the current block, a predicted block for thecurrent block may be derived based on a reference block specified by amotion vector on a reference picture.

In this case, in order to reduce the amount of motion informationtransmitted in an inter prediction mode, motion information of thecurrent block may be derived based on correlation of motion informationbetween a neighboring block and the current block, and motioninformation may be derived in units of blocks, subblocks or samples. Themotion information may include a motion vector and a reference pictureindex. The motion information may further include inter prediction typeinformation. Here, the inter prediction type information may meandirectional information of inter prediction. The inter prediction typeinformation may indicate that a current block is predicted using one ofL0 prediction, L1 prediction or Bi-prediction.

When applying inter prediction to the current block, the neighboringblock of the current block may include a spatial neighboring blockpresent in the current picture and a temporal neighboring block presentin the reference picture. A reference picture including the referenceblock for the current block and a reference picture including thetemporal neighboring block may be the same or different. The temporalneighboring block may be referred to as a collocated reference block orcollocated CU (colCU), and the reference picture including the temporalneighboring block may be referred to as a collocated picture (colPic).

Meanwhile, a motion information candidate list may be constructed basedon the neighboring blocks of the current block, and, in this case, flagor index information indicating which candidate is used may be signaledin order to derive the motion vector of the current block and/or thereference picture index.

The motion information may include L0 motion information and/or L1motion information according to the inter prediction type. The motionvector in an L0 direction may be defined as an L0 motion vector or MVL0,and the motion vector in an L1 direction may be defined as an L1 motionvector or MVL1. Prediction based on the L0 motion vector may be definedas L0 prediction, prediction based on the L1 motion vector may bedefined as L1 prediction, and prediction based both the L0 motion vectorand the L1 motion vector may be defined as Bi-prediction. Here, the L0motion vector may mean a motion vector associated with a referencepicture list L0 and the L1 motion vector may mean a motion vectorassociated with a reference picture list L1.

The reference picture list L0 may include pictures before the currentpicture in output order as reference pictures, and the reference picturelist L1 may include pictures after the current picture in output order.The previous pictures may be defined as forward (reference) pictures andthe subsequent pictures may be defined as backward (reference) pictures.Meanwhile, the reference picture list L0 may further include picturesafter the current picture in output order as reference pictures. In thiscase, within the reference picture list L0, the previous pictures may befirst indexed and the subsequent pictures may then be indexed. Thereference picture list L1 may further include pictures before thecurrent picture in output order as reference pictures. In this case,within the reference picture list L1, the subsequent pictures may befirst indexed and the previous pictures may then be indexed. Here, theoutput order may correspond to picture order count (POC) order.

FIG. 4 is a flowchart illustrating an inter prediction based video/imageencoding method.

FIG. 5 is a view illustrating the configuration of an inter predictor180 according to the present disclosure.

The encoding method of FIG. 6 may be performed by the image encodingapparatus of FIG. 2 . Specifically, step S410 may be performed by theinter predictor 180, and step S420 may be performed by the residualprocessor. Specifically, step S420 may be performed by the subtractor115. Step S430 may be performed by the entropy encoder 190. Theprediction information of step S630 may be derived by the interpredictor 180, and the residual information of step S630 may be derivedby the residual processor. The residual information is information onthe residual samples. The residual information may include informationon quantized transform coefficients for the residual samples. Asdescribed above, the residual samples may be derived as transformcoefficients through the transformer 120 of the image encodingapparatus, and the transform coefficient may be derived as quantizedtransform coefficients through the quantizer 130. Information on thequantized transform coefficients may be encoded by the entropy encoder190 through a residual coding procedure.

The image encoding apparatus may perform inter prediction with respectto a current block (S410). The image encoding apparatus may derive aninter prediction mode and motion information of the current block andgenerate prediction samples of the current block. Here, inter predictionmode determination, motion information derivation and prediction samplesgeneration procedures may be simultaneously performed or any one thereofmay be performed before the other procedures. For example, as shown inFIG. 5 , the inter prediction unit 180 of the image encoding apparatusmay include a prediction mode determination unit 181, a motioninformation derivation unit 182 and a prediction sample derivation unit183. The prediction mode determination unit 181 may determine theprediction mode of the current block, the motion information derivationunit 182 may derive the motion information of the current block, and theprediction sample derivation unit 183 may derive the prediction samplesof the current block. For example, the inter prediction unit 180 of theimage encoding apparatus may search for a block similar to the currentblock within a predetermined area (search area) of reference picturesthrough motion estimation, and derive a reference block whose differencefrom the current block is equal to or less than a predeterminedcriterion or a minimum. Based on this, a reference picture indexindicating a reference picture in which the reference block is locatedmay be derived, and a motion vector may be derived based on a positiondifference between the reference block and the current block. The imageencoding apparatus may determine a mode applying to the current blockamong various inter prediction modes. The image encoding apparatus maycompare rate-distortion (RD) costs for the various prediction modes anddetermine an optimal inter prediction mode of the current block.However, the method of determining the inter prediction mode of thecurrent block by the image encoding apparatus is not limited to theabove example, and various methods may be used.

For example, the inter prediction mode of the current block may bedetermined to be at least one of a merge mode, a merge skip mode, amotion vector prediction (MVP) mode, a symmetric motion vectordifference (SMVD) mode, an affine mode, a subblock-based merge mode, anadaptive motion vector resolution (AMVR) mode, a history-based motionvector predictor (HMVP) mode, a pair-wise average merge mode, a mergemode with motion vector differences (MMVD) mode, a decoder side motionvector refinement (DMVR) mode, a combined inter and intra prediction(CIIP) mode or a geometric partitioning mode (GPM).

For example, when a skip mode or a merge mode applies to the currentblock, the image encoding apparatus may derive merge candidates fromneighboring blocks of the current block and construct a merge candidatelist using the derived merge candidates. In addition, the image encodingapparatus may derive a reference block whose difference from the currentblock is equal to or less than a predetermined criterion or a minimum,among reference blocks indicated by merge candidates included in themerge candidate list. In this case, a merge candidate associated withthe derived reference block may be selected, and merge index informationindicating the selected merge candidate may be generated and signaled toan image decoding apparatus. The motion information of the current blockmay be derived using the motion information of the selected mergecandidate.

As another example, when an MVP mode applies to the current block, theimage encoding apparatus may derive motion vector predictor (MVP)candidates from the neighboring blocks of the current block andconstruct an MVP candidate list using the derived MVP candidates. Inaddition, the image encoding apparatus may use the motion vector of theMVP candidate selected from among the MVP candidates included in the MVPcandidate list as the MVP of the current block. In this case, forexample, the motion vector indicating the reference block derived by theabove-described motion estimation may be used as the motion vector ofthe current block, an MVP candidate with a motion vector having asmallest difference from the motion vector of the current block amongthe MVP candidates may be the selected MVP candidate. A motion vectordifference (MVD) which is a difference obtained by subtracting the MVPfrom the motion vector of the current block may be derived. In thiscase, index information indicating the selected MVP candidate andinformation on the MVD may be signaled to the image decoding apparatus.In addition, when applying the MVP mode, the value of the referencepicture index may be constructed as reference picture index informationand separately signaled to the image decoding apparatus.

The image encoding apparatus may derive residual samples based on theprediction samples (S420). The image encoding apparatus may derive theresidual samples through comparison between original samples of thecurrent block and the prediction samples. For example, the residualsample may be derived by subtracting a corresponding prediction samplefrom an original sample.

The image encoding apparatus may encode image information includingprediction information and residual information (S430). The imageencoding apparatus may output the encoded image information in the formof a bitstream. The prediction information may include prediction modeinformation (e.g., skip flag, merge flag or mode index, etc.) andinformation on motion information as information related to theprediction procedure. Among the prediction mode information, the skipflag indicates whether a skip mode applies to the current block, and themerge flag indicates whether the merge mode applies to the currentblock. Alternatively, the prediction mode information may indicate oneof a plurality of prediction modes, such as a mode index. When the skipflag and the merge flag are 0, it may be determined that the MVP modeapplies to the current block. The information on the motion informationmay include candidate selection information (e.g., merge index, mvp flagor mvp index) which is information for deriving a motion vector. Amongthe candidate selection information, the merge index may be signaledwhen the merge mode applies to the current block and may be informationfor selecting one of merge candidates included in a merge candidatelist. Among the candidate selection information, the MVP flag or the MVPindex may be signaled when the MVP mode applies to the current block andmay be information for selecting one of MVP candidates in an MVPcandidate list. Specifically, the MVP flag may be signaled using asyntax element mvp_10_flag or mvp_11_flag. In addition, the informationon the motion information may include information on the above-describedMVD and/or reference picture index information. In addition, theinformation on the motion information may include information indicatingwhether to apply L0 prediction, L1 prediction or Bi-prediction. Theresidual information is information on the residual samples. Theresidual information may include information on quantized transformcoefficients for the residual samples.

The output bitstream may be stored in a (digital) storage medium andtransmitted to the image decoding apparatus or may be transmitted to theimage decoding apparatus via a network.

As described above, the image encoding apparatus may generate areconstructed picture (a picture including reconstructed samples and areconstructed block) based on the reference samples and the residualsamples. This is for the image encoding apparatus to derive the sameprediction result as that performed by the image decoding apparatus,thereby increasing coding efficiency. Accordingly, the image encodingapparatus may store the reconstructed picture (or the reconstructedsamples and the reconstructed block) in a memory and use the same as areference picture for inter prediction. As described above, an in-loopfiltering procedure is further applicable to the reconstructed picture.

FIG. 6 is a flowchart illustrating an inter prediction based video/imagedecoding method.

FIG. 7 is a view illustrating the configuration of an inter predictionunit 260 according to the present disclosure.

The image decoding apparatus may perform operation corresponding tooperation performed by the image encoding apparatus. The image decodingapparatus may perform prediction with respect to a current block basedon received prediction information and derive prediction samples.

The decoding method of FIG. 6 may be performed by the image decodingapparatus of FIG. 3 . Steps S610 to S630 may be performed by the interprediction unit 260, and the prediction information of step S610 and theresidual information of step S640 may be obtained from a bitstream bythe entropy decoder 210. The residual processor of the image decodingapparatus may derive residual samples for a current block based on theresidual information (S640). Specifically, the dequantizer 220 of theresidual processor may perform dequantization based on quantizedtransform coefficients derived based on the residual information toderive transform coefficients, and the inverse transformer 230 of theresidual processor may perform inverse transform with respect to thetransform coefficients to derive the residual samples for the currentblock. Step S650 may be performed by the adder 235 or the reconstructor.

Specifically, the image decoding apparatus may determine the predictionmode of the current block based on the received prediction information(S610). The image decoding apparatus may determine which interprediction mode applies to the current block based on the predictionmode information in the prediction information.

For example, it may be determined whether the skip mode applies to thecurrent block based on the skip flag. In addition, it may be determinedwhether the merge mode or the MVP mode applies to the current blockbased on the merge flag. Alternatively, one of various inter predictionmode candidates may be selected based on the mode index. The interprediction mode candidates may include a skip mode, a merge mode and/oran MVP mode or may include various inter prediction modes which will bedescribed below.

The image decoding apparatus may derive the motion information of thecurrent block based on the determined inter prediction mode (S620). Forexample, when the skip mode or the merge mode applies to the currentblock, the image decoding apparatus may construct a merge candidatelist, which will be described below, and select one of merge candidatesincluded in the merge candidate list. The selection may be performedbased on the above-described candidate selection information (mergeindex). The motion information of the current block may be derived usingthe motion information of the selected merge candidate. For example, themotion information of the selected merge candidate may be used as themotion information of the current block.

As another example, when the MVP mode applies to the current block, theimage decoding apparatus may construct an MVP candidate list and use themotion vector of an MVP candidate selected from among MVP candidatesincluded in the MVP candidate list as an MVP of the current block. Theselection may be performed based on the above-described candidateselection information (mvp flag or mvp index). In this case, the MVD ofthe current block may be derived based on information on the MVD, andthe motion vector of the current block may be derived based on MVP andMVD of the current block. In addition, the reference picture index ofthe current block may be derived based on the reference picture indexinformation. A picture indicated by the reference picture index in thereference picture list of the current block may be derived as areference picture referenced for inter prediction of the current block.

The image decoding apparatus may generate prediction samples of thecurrent block based on motion information of the current block (S630).In this case, the reference picture may be derived based on thereference picture index of the current block, and the prediction samplesof the current block may be derived using the samples of the referenceblock indicated by the motion vector of the current block on thereference picture. In some cases, a prediction sample filteringprocedure may be further performed with respect to all or some of theprediction samples of the current block.

For example, as shown in FIG. 7 , the inter prediction unit 260 of theimage decoding apparatus may include a prediction mode determinationunit 261, a motion information derivation unit 262 and a predictionsample derivation unit 263. In the inter prediction unit 260 of theimage decoding apparatus, the prediction mode determination unit 261 maydetermine the prediction mode of the current block based on the receivedprediction mode information, the motion information derivation unit 262may derive the motion information (a motion vector and/or a referencepicture index, etc.) of the current block based on the received motioninformation, and the prediction sample derivation unit 263 may derivethe prediction samples of the current block.

The image decoding apparatus may generate residual samples of thecurrent block based the received residual information (S640). The imagedecoding apparatus may generate the reconstructed samples of the currentblock based on the prediction samples and the residual samples andgenerate a reconstructed picture based on this (S650). Thereafter, anin-loop filtering procedure is applicable to the reconstructed pictureas described above.

As described above, the inter prediction procedure may include step ofdetermining an inter prediction mode, step of deriving motioninformation according to the determined prediction mode, and step ofperforming prediction (generating prediction samples) based on thederived motion information. The inter prediction procedure may beperformed by the image encoding apparatus and the image decodingapparatus, as described above.

Hereinafter, the step of deriving the motion information according tothe prediction mode will be described in greater detail.

As described above, inter prediction may be performed using motioninformation of a current block. An image encoding apparatus may deriveoptimal motion information of a current block through a motionestimation procedure. For example, the image encoding apparatus maysearch for a similar reference block with high correlation within apredetermined search range in the reference picture using an originalblock in an original picture for the current block in fractional pixelunit, and derive motion information using the same. Similarity of theblock may be calculated based on a sum of absolute differences (SAD)between the current block and the reference block. In this case, motioninformation may be derived based on a reference block with a smallestSAD in the search area. The derived motion information may be signaledto an image decoding apparatus according to various methods based on aninter prediction mode.

When a merge mode applies to a current block, motion information of thecurrent block is not directly transmitted and motion information of thecurrent block is derived using motion information of a neighboringblock. Accordingly, motion information of a current prediction block maybe indicated by transmitting flag information indicating that the mergemode is used and candidate selection information (e.g., a merge index)indicating which neighboring block is used as a merge candidate. In thepresent disclosure, since the current block is a unit of predictionperformance, the current block may be used as the same meaning as thecurrent prediction block, and the neighboring block may be used as thesame meaning as a neighboring prediction block.

The image encoding apparatus may search for merge candidate blocks usedto derive the motion information of the current block to perform themerge mode. For example, up to five merge candidate blocks may be used,without being limited thereto. The maximum number of merge candidateblocks may be transmitted in a slice header or a tile group header,without being limited thereto. After finding the merge candidate blocks,the image encoding apparatus may generate a merge candidate list andselect a merge candidate block with smallest RD cost as a final mergecandidate block.

The present disclosure provides various embodiments for the mergecandidate blocks configuring the merge candidate list. The mergecandidate list may use, for example, five merge candidate blocks. Forexample, four spatial merge candidates and one temporal merge candidatemay be used.

FIG. 8 is a view illustrating neighboring blocks available as a spatialmerge candidate.

FIG. 9 is a view schematically illustrating a merge candidate listconstruction method according to an example of the present disclosure.

An image encoding/decoding apparatus may insert, into a merge candidatelist, spatial merge candidates derived by searching for spatialneighboring blocks of a current block (S910). For example, as shown inFIG. 8 , the spatial neighboring blocks may include a bottom-left cornerneighboring block A₀, a left neighboring block A₁, a top-right cornerneighboring block B₀, a top neighboring block B₁, and a top-left cornerneighboring block B₂ of the current block. However, this is an exampleand, in addition to the above-described spatial neighboring blocks,additional neighboring blocks such as a right neighboring block, abottom neighboring block and a bottom-right neighboring block may befurther used as the spatial neighboring blocks. The imageencoding/decoding apparatus may detect available blocks by searching forthe spatial neighboring blocks based on priority and derive motioninformation of the detected blocks as the spatial merge candidates. Forexample, the image encoding/decoding apparatus may construct a mergecandidate list by searching for the five blocks shown in FIG. 8 in orderof A₁, B₁, B₀, A₀ and B₂ and sequentially indexing available candidates.

The image encoding/decoding apparatus may insert, into the mergecandidate list, a temporal merge candidate derived by searching fortemporal neighboring blocks of the current block (S920). The temporalneighboring blocks may be located on a reference picture which isdifferent from a current picture in which the current block is located.A reference picture in which the temporal neighboring block is locatedmay be referred to as a collocated picture or a col picture. Thetemporal neighboring block may be searched for in order of abottom-right corner neighboring block and a bottom-right center block ofthe co-located block for the current block on the col picture.Meanwhile, when applying motion data compression in order to reducememory load, specific motion information may be stored as representativemotion information for each predetermined storage unit for the colpicture. In this case, motion information of all blocks in thepredetermined storage unit does not need to be stored, thereby obtainingmotion data compression effect. In this case, the predetermined storageunit may be predetermined as, for example, 16×16 sample unit or 8×8sample unit or size information of the predetermined storage unit may besignaled from the image encoding apparatus to the image decodingapparatus. When applying the motion data compression, the motioninformation of the temporal neighboring block may be replaced with therepresentative motion information of the predetermined storage unit inwhich the temporal neighboring block is located. That is, in this case,from the viewpoint of implementation, the temporal merge candidate maybe derived based on the motion information of a prediction blockcovering an arithmetic left-shifted position after an arithmetic rightshift by a predetermined value based on coordinates (top-left sampleposition) of the temporal neighboring block, not a prediction blocklocated on the coordinates of the temporal neighboring block. Forexample, when the predetermined storage unit is a 2^(n)×2^(n) sampleunit and the coordinates of the temporal neighboring block are (xTnb,yTnb), the motion information of a prediction block located at amodified position ((xTnb>>n)<<n), (yTnb>>n)<<n)) may be used for thetemporal merge candidate. Specifically, for example, when thepredetermined storage unit is a 16×16 sample unit and the coordinates ofthe temporal neighboring block are (xTnb, yTnb), the motion informationof a prediction block located at a modified position ((xTnb>>4)<<4),(yTnb>>4)<<4)) may be used for the temporal merge candidate.Alternatively, for example, when the predetermined storage unit is an8×8 sample unit and the coordinates of the temporal neighboring blockare (xTnb, yTnb), the motion information of a prediction block locatedat a modified position ((xTnb>>3)<<3), (yTnb>>3)<<3)) may be used forthe temporal merge candidate.

Referring to FIG. 9 again, the image encoding/decoding apparatus maycheck whether the current number of merge candidates is less than amaximum number of merge candidates (S930). The maximum number of mergecandidates may be predefined or signaled from the image encodingapparatus to the image decoding apparatus. For example, the imageencoding apparatus may generate and encode information on the maximumnumber of merge candidates and transmit the encoded information to theimage decoding apparatus in the form of a bitstream. When the maximumnumber of merge candidates is satisfied, a subsequent candidate additionprocess S940 may not be performed.

When the current number of merge candidates is less than the maximumnumber of merge candidates as a checked result of step S930, the imageencoding/decoding apparatus may derive an additional merge candidateaccording to a predetermined method and then insert the additional mergecandidate to the merge candidate list (S940). The additional mergecandidate may include, for example, at least one of history based mergecandidate(s), pair-wise average merge candidate(s), ATMVP, combinedbi-predictive merge candidate(s) (when a slice/tile group type of acurrent slice/tile group is a B type) and/or zero vector mergecandidate(s).

When the current number of merge candidates is not less than the maximumnumber of merge candidates as a checked result of step S930, the imageencoding/decoding apparatus may end the construction of the mergecandidate list. In this case, the image encoding apparatus may select anoptimal merge candidate from among the merge candidates configuring themerge candidate list, and signal candidate selection information (e.g.,merge candidate index or merge index) indicating the selected mergecandidate to the image decoding apparatus. The image decoding apparatusmay select the optimal merge candidate based on the merge candidate listand the candidate selection information.

The motion information of the selected merge candidate may be used asthe motion information of the current block, and the prediction samplesof the current block may be derived based on the motion information ofthe current block, as described above. The image encoding apparatus mayderive the residual samples of the current block based on the predictionsamples and signal residual information of the residual samples to theimage decoding apparatus. The image decoding apparatus may generatereconstructed samples based on the residual samples derived based on theresidual information and the prediction samples and generate thereconstructed picture based on the same, as described above.

When applying a skip mode to the current block, the motion informationof the current block may be derived using the same method as the case ofapplying the merge mode. However, when applying the skip mode, aresidual signal for a corresponding block is omitted and thus theprediction samples may be directly used as the reconstructed samples.The above skip mode may apply, for example, when the value ofcu_skip_flag is 1.

Hereinafter, a method of deriving a spatial candidate in a merge modeand/or a skip mode will be described. The spatial candidate mayrepresent the above-described spatial merge candidate.

Derivation of the spatial candidate may be performed based on spatiallyneighboring blocks. For example, a maximum of four spatial candidatesmay be derived from candidate blocks existing at positions shown in FIG.8 . The order of deriving spatial candidates may be A1->B1->B0->A0->B2.However, the order of deriving spatial candidates is not limited to theabove order and may be, for example, B1->A1->B0->A0->B2. The lastposition in the order (position B2 in the above example) may beconsidered when at least one of the preceding four positions (A1, B1, B0and A0 in the above example) is not available. In this case, a block ata predetermined position being not available may include a correspondingblock belonging to a slice or tile different from the current block or acorresponding block being an intra-predicted block. When a spatialcandidate is derived from a first position in the order (A1 or B1 in theabove example), redundancy check may be performed on spatial candidatesof subsequent positions. For example, when motion information of asubsequent spatial candidate is the same as motion information of aspatial candidate already included in a merge candidate list, thesubsequent spatial candidate may not be included in the merge candidatelist, thereby improving encoding efficiency. Redundancy check performedon the subsequent spatial candidate may be performed on some candidatepairs instead of all possible candidate pairs, thereby reducingcomputational complexity.

FIG. 10 is a view illustrating a candidate pair for redundancy checkperformed on a spatial candidate.

In the example shown in FIG. 10 , redundancy check for a spatialcandidate at a position B₀ may be performed only for a spatial candidateat a position A₀. In addition, redundancy check for a spatial candidateat a position B₁ may be performed only for a spatial candidate at aposition B₀. In addition, redundancy check for a spatial candidate at aposition A₁ may be performed only for a spatial candidate at a positionA₀. Finally, redundancy check for a spatial candidate at a position B₂may be performed only for spatial candidates at a position A₀ and aposition B₀.

In the example shown in FIG. 10 , the order of deriving the spatialcandidates is A0->B0->B1->A1->B2. However, the present disclosure is notlimited thereto and, even if the order of deriving the spatialcandidates is changed, as in the example shown in FIG. 10 , redundancycheck may be performed only on some candidate pairs.

Hereinafter, a method of deriving a temporal candidate in the case of amerge mode and/or a skip mode will be described. The temporal candidatemay represent the above-described temporal merge candidate. In addition,the motion vector of the temporal candidate may correspond to thetemporal candidate of an MVP mode.

In the case of the temporal candidate, only one candidate may beincluded in a merge candidate list. In the process of deriving thetemporal candidate, the motion vector of the temporal candidate may bescaled. For example, the scaling may be performed based on a collocatedblock (CU) (hereinafter referred to as a “col block”) belonging to acollocated reference picture (colPic) (hereinafter referred to as “colpicture”). A reference picture list used to derive the col block may beexplicitly signaled in a slice header.

FIG. 11 is a view illustrating a method of scaling a motion vector of atemporal candidate.

In FIG. 11 , curr_CU and curr_pic respectively denote a current blockand a current picture, and col_CU and col_pic respectively denote a colblock and a col picture. In addition, curr_ref denote a referencepicture of a current block, and col_ref denotes a reference picture of acol block. In addition, tb denotes a distance between the referencepicture of the current block and the current picture, and td denotes adistance between the reference picture of the col block and the colpicture. tb and td may denote values corresponding to differences in POC(Picture Order Count) between pictures. Scaling of the motion vector ofthe temporal candidate may be performed based on tb and td. In addition,the reference picture index of the temporal candidate may be set to 0.

FIG. 12 is a view illustrating a position where a temporal candidate isderived.

In FIG. 12 , a block with a thick solid line denotes a current block. Atemporal candidate may be derived from a block in a col picturecorresponding to a position C₀ (bottom-right position) or C₁ (centerposition) of FIG. 12 . First, it may be determined whether the positionC₀ is available and, when the position C₀ is available, the temporalcandidate may be derived based on the position C₀. When the position C₀is not available, the temporal candidate may be derived based on theposition C₁. For example, when a block in the col picture at theposition C₀ is an intra-predicted block or is located outside a currentCTU row, it may be determined that the position C₀ is not available.

As described above, when applying motion data compression, the motionvector of the col block may be stored for each predetermined unit block.In this case, in order to derive the motion vector of a block coveringthe position C₀ or the position C₁, the position C₀ or the position C₁may be modified. For example, when the predetermined unit block is an8×8 block and the position C₀ or the position C₁ is (xColCi, yColCi), aposition for deriving the temporal candidate may be modified to((xColCi>>3)<<3, (yColCi>>3)<<3).

Hereinafter, a method of deriving a history-based candidate in the caseof a merge mode and/or a skip mode will be described. The history-basedcandidate may be expressed by a history-based merge candidate.

The history-based candidate may be added to a merge candidate list aftera spatial candidate and a temporal candidate are added to the mergecandidate list. For example, motion information of a previouslyencoded/decoded block may be stored at a table and used as ahistory-based candidate of a current block. The table may store aplurality of history-based candidates during the encoding/decodingprocess. The table may be initialized when a new CTU row starts.Initializing the table may mean that the corresponding table is emptiedby deleting all the history-based candidates stored in the table.Whenever there is an inter-predicted block, related motion informationmay be added to the table as a last entry. In this case, theinter-predicted block may not be a block predicted based on a subblock.The motion information added to the table may be used as a newhistory-based candidate.

The table of the history-based candidates may have a predetermined size.For example, the size may be 5. In this case, the table may store amaximum of five history-based candidates. When a new candidate is addedto the table, a limited first-in-first-out (FIFO) rule in whichredundancy check of checking whether the same candidate is present inthe table may apply. If the same candidate is already present in thetable, the same candidate may be deleted from the table and positions ofall subsequent history-based candidates may be moved forward.

The history-based candidate may be used in a process of configuring themerge candidate list. In this case, the history-based candidatesrecently included in the table may be sequentially checked and locatedat a position after the temporal candidate of the merge candidate list.When the history-based candidate is included in the merge candidatelist, redundancy check with the spatial candidates or temporalcandidates already included in the merge candidate list may beperformed. If the spatial candidate or temporal candidate alreadyincluded in the merge candidate list and the history-based candidateoverlap, the history-based candidate may not be included in the mergecandidate list. By simplifying the redundancy check as follows, theamount of computation may be reduced.

The number of history-based candidates used to generate the mergecandidate list may be set to (N<=4)?M:(8−N). In this case, N may denotethe number of candidates already included in the merge candidate list,and M may denote the number of available history-based candidateincluded in the table. That is, when 4 or less candidates are includedin the merge candidate list, the number of history-based candidates usedto generate the merge candidate list may be M, and, when N candidatesgreater than 4 are included in the merge candidate list, the number ofhistory-based candidates used to generate the merge candidate list maybe set to (8−N).

When the total number of available merge candidates reaches (maximumallowable number of merge candidates−1), configuration of the mergecandidate list using the history-based candidate may end.

Hereinafter, a method of deriving a pair-wise average candidate in thecase of a merge mode and/or a skip mode will be described. The pair-wiseaverage candidate may be represented by a pair-wise average mergecandidate or a pair-wise candidate.

The pair-wise average candidate may be generated by obtaining predefinedcandidate pairs from the candidates included in the merge candidate listand averaging them. The predefined candidate pairs may be {(0, 1), (0,2), (1, 2), (0, 3), (1, 3), (2, 3)} and the number configuring eachcandidate pair may be an index of the merge candidate list. That is, thepredefined candidate pair (0, 1) may mean a pair of index 0 candidateand index 1 candidate of the merge candidate list, and the pair-wiseaverage candidate may be generated by an average of index 0 candidateand index 1 candidate. Derivation of pair-wise average candidates may beperformed in the order of the predefined candidate pairs. That is, afterderiving a pair-wise average candidate for the candidate pair (0, 1),the process of deriving the pair-wise average candidate may be performedin order of the candidate pair (0, 2) and the candidate pair (1, 2). Thepair-wise average candidate derivation process may be performed untilconfiguration of the merge candidate list is completed. For example, thepair-wise average candidate derivation process may be performed untilthe number of merge candidates included in the merge candidate listreaches a maximum merge candidate number.

The pair-wise average candidate may be calculated separately for eachreference picture list. When two motion vectors are available for onereference picture list (L0 list or L1 list), an average of the twomotion vectors may be computed. In this case, even if the two motionvectors indicate different reference pictures, an average of the twomotion vectors may be performed. If only one motion vector is availablefor one reference picture list, an available motion vector may be usedas a motion vector of a pair-wise average candidate. If both the twomotion vectors are not available for one reference picture list, it maybe determined that the reference picture list is not valid.

When configuration of the merge candidate list is not completed evenafter the pair-wise average candidate is included in the merge candidatelist, a zero vector may be added to the merge candidate list until themaximum merge candidate number is reached.

When applying an MVP mode to the current block, a motion vectorpredictor (mvp) candidate list may be generated using a motion vector ofa reconstructed spatial neighboring block (e.g., the neighboring blockshown in FIG. 8 ) and/or a motion vector corresponding to the temporalneighboring block (or Col block). That is, the motion vector of thereconstructed spatial neighboring blocks and the motion vectorcorresponding to the temporal neighboring blocks may be used as motionvector predictor candidates of the current block. When applyingbi-prediction, an mvp candidate list for L0 motion informationderivation and an mvp candidate list for L1 motion informationderivation are individually generated and used. Prediction information(or information on prediction) of the current block may includecandidate selection information (e.g., an MVP flag or an MVP index)indicating an optimal motion vector predictor candidate selected fromamong the motion vector predictor candidates included in the mvpcandidate list. In this case, a prediction unit may select a motionvector predictor of a current block from among the motion vectorpredictor candidates included in the mvp candidate list using thecandidate selection information. The prediction unit of the imageencoding apparatus may obtain and encode a motion vector difference(MVD) between the motion vector of the current block and the motionvector predictor and output the encoded MVD in the form of a bitstream.That is, the MVD may be obtained by subtracting the motion vectorpredictor from the motion vector of the current block. The predictionunit of the image decoding apparatus may obtain a motion vectordifference included in the information on prediction and derive themotion vector of the current block through addition of the motion vectordifference and the motion vector predictor. The prediction unit of theimage decoding apparatus may obtain or derive a reference picture indexindicating a reference picture from the information on prediction.

FIG. 13 is a view schematically illustrating a motion vector predictorcandidate list construction method according to an example of thepresent disclosure.

First, a spatial candidate block of a current block may be searched forand available candidate blocks may be inserted into an MVP candidatelist (S1010). Thereafter, it is determined whether the number of MVPcandidates included in the MVP candidate list is less than 2 (S1020)and, when the number of MVP candidates is two, construction of the MVPcandidate list may be completed.

In step S1020, when the number of available spatial candidate blocks isless than 2, a temporal candidate block of the current block may besearched for and available candidate blocks may be inserted into the MVPcandidate list (S1030). When the temporal candidate blocks are notavailable, a zero motion vector may be inserted into the MVP candidatelist (S1040), thereby completing construction of the MVP candidate list.

Meanwhile, when applying an mvp mode, a reference picture index may beexplicitly signaled. In this case, a reference picture index refidxL0for L0 prediction and a reference picture index refidxL1 for L1prediction may be distinguishably signaled. For example, when applyingthe MVP mode and applying Bi-prediction, both information on refidxL0and information on refidxL1 may be signaled.

As described above, when applying the MVP mode, information on MVPderived by the image encoding apparatus may be signaled to the imagedecoding apparatus. Information on the MVD may include, for example, anMVD absolute value and information indicating x and y components for asign. In this case, when the MVD absolute value is greater than 0,whether the MVD absolute value is greater than 1 and informationindicating an MVD remainder may be signaled stepwise. For example,information indicating whether the MVD absolute value is greater than 1may be signaled only when a value of flag information indicating whetherthe MVD absolute value is greater than 0 is 1.

Overview of Affine Mode

Hereinafter, an affine mode which is an example of an inter predictionmode will be described in detail. In a conventional videoencoding/decoding system, only one motion vector is used to expressmotion information of a current block. However, in this method, there isa problem in that optimal motion information is only expressed in unitsof blocks, but optimal motion information cannot be expressed in unitsof pixels. In order to solve this problem, an affine mode definingmotion information of a block in units of pixels has been proposed.According to the affine mode, a motion vector for each pixel and/orsubblock unit of a block may be determined using two to four motionvectors associated with a current block.

Compared to the existing motion information expressed using translationmotion (or displacement) of a pixel value, in the affine mode, motioninformation for each pixel may be expressed using at least one oftranslation motion, scaling, rotation or shear. Among them, an affinemode in which motion information for each pixel is expressed usingdisplacement, scaling or rotation may be similarity or simplified affinemode. The affine mode in the following description may mean a similarityor simplified affine mode.

Motion information in the affine mode may be expressed using two or morecontrol point motion vectors (CPMVs). A motion vector of a specificpixel position of a current block may be derived using a CPMV. In thiscase, a set of motion vectors for each pixel and/or subblock of acurrent block may be defined as an affine motion vector field (affineMVF).

FIG. 14 is a view illustrating a parameter model of an affine mode.

When an affine mode applies to a current block, an affine MVF may bederived using one of a 4-parameter model and a 6-parameter model. Inthis case, the 4-parameter model may mean a model type in which twoCPMVs are used and the 6-parameter model may mean a model type in whichthree CPMVs are used. FIGS. 14(a) and 14(b) show CPMVs used in the4-parameter model and the 6-parameter model, respectively.

When the position of the current block is (x, y), a motion vectoraccording to the pixel position may be derived according to Equation 1or 2 below. For example, the motion vector according to the 4-parametermodel may be derived according to Equation 1 and the motion vectoraccording to the 6-parameter model may be derived according to Equation2.

$\begin{matrix}\{ \begin{matrix}{{mv}_{x} = {{\frac{{mv}_{1x} - {mv}_{0x}}{W}x} + {\frac{{mv}_{1y} - {mv}_{0y}}{W}y} + {mv}_{0x}}} \\{{mv}_{y} = {{\frac{{mv}_{1y} - {mv}_{0y}}{W}x} + {\frac{{mv}_{1x} - {mv}_{0x}}{W}y} + {mv}_{0y}}}\end{matrix}  & \lbrack {{Equation}1} \rbrack\end{matrix}$ $\begin{matrix}\{ \begin{matrix}{{mv}_{x} = {{\frac{{mv}_{1x} - {mv}_{0x}}{W}x} + {\frac{{mv}_{2x} - {mv}_{0x}}{H}y} + {mv}_{0x}}} \\{{mv}_{y} = {{\frac{{mv}_{1y} - {mv}_{0y}}{W}x} + {\frac{{mv}_{2y} - {mv}_{0y}}{H}y} + {mv}_{0y}}}\end{matrix}  & \lbrack {{Equation}2} \rbrack\end{matrix}$

In Equations 1 and 2, mv0={mv_0x, mv_0y} may be a CPMV at the top leftcorner position of the current block, v1={mv_1x, mv_1y} may be a CPMV atthe top right position of the current block, and mv2={mv_2x, mv_2y} maybe a CPMV at the bottom left position of the current block. In thiscase, W and H respectively correspond to the width and height of thecurrent block, and mv={mv_x, mv_y} may mean a motion vector of a pixelposition {x, y}.

In an encoding/decoding process, an affine MVF may be determined inunits of pixels and/or predefined subblocks. When the affine MVF isdetermined in units of pixels, a motion vector may be derived based oneach pixel value. Meanwhile, when the affine MVF is determined in unitsof subblocks, a motion vector of a corresponding block may be derivedbased on a center pixel value of a subblock. The center pixel value maymean a virtual pixel present in the center of a subblock or a bottomright pixel among four pixels present in the center. In addition, thecenter pixel value may be a specific pixel in a subblock and may be apixel representing the subblock. In the present disclosure, the casewhere the affine MVF is determined in units of 4×4 subblocks will bedescribed. However, this is only for convenience of description and thesize of the subblock may be variously changed.

That is, when affine prediction is available, a motion model applicableto a current block may include three models, that is, a translationalmotion model, a 4-parameter affine motion model and 6-parameter affinemotion model. Here, the translational motion model may represent a modelused by an existing block unit motion vector, the 4-parameter affinemotion model may represent a model used by two CPMVs, and the6-parameter affine motion model may represent a model used by threeCPMVs. The affine mode may be divided into detailed modes according to amethod of encoding/decoding motion information. For example, the affinemode may be subdivided into an affine MVP mode and an affine merge mode.

When an affine merge mode applies for a current block, a CPMV may bederived from neighboring blocks of the current block encoded/decoded inthe affine mode. When at least one of the neighboring blocks of thecurrent block is encoded/decoded in the affine mode, the affine mergemode may apply for the current block. That is, when the affine mergemode applies for the current block, CPMVs of the current block may bederived using CPMVs of the neighboring blocks. For example, the CPMVs ofthe neighboring blocks may be determined to be the CPMVs of the currentblock or the CPMV of the current block may be derived based on the CPMVsof the neighboring blocks. When the CPMV of the current block is derivedbased on the CPMVs of the neighboring blocks, at least one of codingparameters of the current block or the neighboring blocks may be used.For example, CPMVs of the neighboring blocks may be modified based onthe size of the neighboring blocks and the size of the current block andused as the CPMVs of the current block.

Meanwhile, affine merge in which an MV is derived in units of subblocksmay be referred to as a subblock merge mode, which may be specified bymerge_subblock_flag having a first value (e.g., 1). In this case, anaffine merging candidate list described below may be referred to as asubblock merging candidate list. In this case, a candidate derived asSbTMVP described below may be further included in the subblock mergingcandidate list. In this case, the candidate derived as sbTMVP may beused as a candidate of index #0 of the subblock merging candidate list.In other words, the candidate derived as sbTMVP may be located in frontof an inherited affine candidates and constructed affine candidatesdescribed below in the subblock merging candidate list.

For example, an affine mode flag specifying whether an affine mode isapplicable to a current block may be defined, which may be signaled atleast one of higher levels of the current block, such as a sequence, apicture, a slice, a tile, a tile group, a brick, etc. For example, theaffine mode flag may be named sps_affine_enabled_flag.

When the affine merge mode applies, an affine merge candidate list maybe configured to derive the CPMV of the current block. In this case, theaffine merge candidate list may include at least one of an inheritedaffine merge candidate, a constructed affine merge candidate or a zeromerge candidate. The inherited affine merge candidate may mean acandidate derived using the CPMVs of the neighboring blocks when theneighboring blocks of the current block are encoded/decoded in theaffine mode. The constructed affine merge candidate may mean a candidatehaving each CPMV derived based on motion vectors of neighboring blocksof each control point (CP). Meanwhile, the zero merge candidate may meana candidate composed of CPMVs having a size of 0. In the followingdescription, the CP may mean a specific position of a block used toderive a CPMV. For example, the CP may be each vertex position of ablock.

FIG. 15 is a view illustrating a method of generating an affine mergecandidate list.

Referring to the flowchart of FIG. 15 , affine merge candidates may beadded to the affine merge candidate list in order of an inherited affinemerge candidate (S1210), a constructed affine merge candidate (S1220)and a zero merge candidate (S1230). The zero merge candidate may beadded when the number of candidates included in the candidate list doesnot satisfy a maximum number of candidates even though all the inheritedaffine merge candidates and the constructed affine merge candidates areadded to the affine merge candidate list. In this case, the zero mergecandidate may be added until the number of candidates of the affinemerge candidate list satisfies the maximum number of candidates.

FIG. 16 is a view illustrating a control point motion vector (CPMV)derived from a neighboring block.

For example, a maximum of two inherited affine merge candidates may bederived, each of which may be derived based on at least one of leftneighboring blocks and top neighboring blocks. Neighboring blocks forderiving the inherited affine merge mode will be described withreference to FIG. 8 . An inherited affine merge candidate derived basedon a left neighboring block is derived based on at least one of A0 orA1, and an inherited affine merge candidate derived based on a topneighboring block may be derived based on at least one of B0, B1 or B2.In this case, the scan order of the neighboring blocks may be A0 to A1and B0, B1 and B2, but is not limited thereto. For each of the left andtop, an inherited affine merge candidates may be derived based on anavailable first neighboring block in the scan order. In this case,redundancy check may not be performed between candidates derived fromthe left neighboring block and the top neighboring block.

For example, as shown in FIG. 16 , when a left neighboring block A isencoded/decoded in the affine mode, at least one of motion vectors v2,v3 and v4 corresponding to the CP of the neighboring block A may bederived. When the neighboring block A is encoded/decoded through a4-parameter affine model, the inherited affine merge candidate may bederived using v2 and v3. In contrast, When the neighboring block A isencoded/decoded through a 6-parameter affine model, the inherited affinemerge candidate may be derived using v2, v3 and v4.

FIG. 17 is a view illustrating neighboring blocks for deriving aconstructed affine merge candidate.

The constructed affine candidate may mean a candidate having a CPMVderived using a combination of general motion information of neighboringblocks. Motion information for each CP may be derived using spatialneighboring blocks or temporal neighboring blocks of the current block.In the following description, CPMVk may mean a motion vectorrepresenting a k-th CP. For example, referring to FIG. 17 , CPMV1 may bedetermined to be an available first motion vector of motion vectors ofB2, B3 and A2, and, in this case, the scan order may be B2, B3 and A2.CPMV2 may be determined to be an available first motion vector of motionvectors of B1 and B0, and, in this case, the scan order may be B1 andB0. CPMV3 may be determined to be one of motion vectors of A1 and A0,and, in this case, the scan order may be A1 and A0. When TMVP isapplicable to the current block, CPMV4 may be determined as a motionvector of T which is a temporal neighboring block.

After four motion vectors for each CP are derived, a constructed affinemerge candidate may be derived based on this. The constructed affinemerge candidate may be configured by including at least two motionvectors selected from among the derived four motion vectors for each CP.For example, the constructed affine merge candidate may be composed ofat least one of {CPMV1, CPMV2, CPMV3}, {CPMV1, CPMV2, CPMV4}, {CPMV1,CPMV3, CPMV4}, {CPMV2, CPMV3, CPMV4}, {CPMV1, CPMV2} or {CPMV1, CPMV3}in this order. A constructed affine candidate composed of three motionvectors may be a candidate for a 6-parameter affine model. In contrast,a constructed affine candidate composed of two motion vectors may be acandidate for a 4-parameter affine model. In order to avoid the scalingprocess of the motion vector, when the reference picture indices of CPsare different from each other, a combination of related CPMVs may beignored without being used to derive the constructed affine candidate.

When an affine MVP mode applies to a current block, an encoding/decodingapparatus may derive two or more CPMV predictors and CPMVs for thecurrent block and derive CPMV differences based on them. In this case,the CPMV differences may be signaled from the encoding apparatus to thedecoding apparatus. The image decoding apparatus may derive a CPMVpredictor for the current block, reconstruct the signaled CPMVdifference, and then derive a CPMV of the current block based on theCPMV predictor and the CPMV difference.

Meanwhile, only when the affine merge mode or a subblock-based TMVP doesnot apply for the current block, an affine MVP mode may apply for thecurrent block. Meanwhile, the affine MVP mode may be expressed as anaffine CP MVP mode.

When the affine MVP applies for the current block, an affine MVPcandidate list may be configured to derive a CPMV for the current block.In this case, the affine MVP candidate list may include at least one ofan inherited affine MVP candidate, a constructed affine MVP candidate, atranslation motion affine MVP candidate or a zero MVP candidate.

In this case, the inherited affine MVP candidate may mean a candidatederived based on the CPMVs of the neighboring blocks, when theneighboring blocks of the current block are encoded/decoded in an affinemode. The constructed affine MVP candidate may mean a candidate derivedby generating a CPMV combination based on a motion vector of a CPneighboring block. The zero MVP candidate may mean a candidate composedof CPMVs having a value of 0. The derivation method and characteristicsof the inherited affine MVP candidate and the constructed affine MVPcandidate are the same as the above-described inherited affine candidateand the constructed affine candidate and thus a description thereof willbe omitted.

When the maximum number of candidates of the affine MVP candidate listis 2, the constructed affine MVP candidate, the translation motionaffine MVP candidate and the zero MVP candidate may be added when thecurrent number of candidates is less than 2. In particular, thetranslation motion affine MVP candidate may be derived in the followingorder.

For example, when the number of candidates included in the affine MVPcandidate list is less than 2 and CPMV0 of the constructed affine MVPcandidate is valid, CPMV0 may be used as an affine MVP candidate. Thatis, affine MVP candidates having all motion vectors of CP0, CP1, CP2being CPMV0 may be added to the affine MVP candidate list.

Next, when the number of candidates of the affine MVP candidate list isless than 2 and CPMV1 of the constructed affine MVP candidate is valid,CPMV1 may be used as an affine MVP candidate. That is, affine MVPcandidates having all motion vectors of CP0, CP1, CP2 being CPMV1 may beadded to the affine MVP candidate list.

Next, when the number of candidates of the affine MVP candidate list isless than 2 and CPMV2 of the constructed affine MVP candidate is valid,CPMV2 may be used as an affine MVP candidate. That is, affine MVPcandidates having all motion vectors of CP0, CP1, CP2 being CPMV2 may beadded to the affine MVP candidate list.

Despite the above-described conditions, when the number of candidates ofthe affine MVP candidate list is less than 2, a temporal motion vectorpredictor (TMVP) of the current block may be added to the affine MVPcandidate list.

Despite addition of the translation motion affine MVP candidate, whenthe number of candidates of the affine MVP candidate list is less than2, the zero MVP candidate may be added to the affine MVP candidate list.

FIG. 18 is a view illustrating a method of generating an affine MVPcandidate list.

Referring to the flowchart of FIG. 18 , candidates may be added to theaffine MVP candidate list in order of an inherited affine MVP candidate(S1610), a constructed affine MVP candidate (S1620), a translationmotion affine MVP candidate (S1630) and a zero MVP candidate (S1640). Asdescribed above, steps S1620 to S1640 may be performed depending onwhether the number of candidates included in the affine MVP candidatelist is less than 2 in each step.

The scan order of the inherited affine MVP candidates may be equal tothe scan order of the inherited affine merge candidates. However, in thecase of the inherited affine MVP candidate, only neighboring blocksreferencing the same reference picture as the reference picture of thecurrent block may be considered. When the inherited affine MVP candidateis added to an affine MVP candidate list, redundancy check may not beperformed.

In order to derive the constructed affine MVP candidate, only spatialneighboring blocks shown in FIG. 17 may be considered. In addition, thescan order of the constructed affine MVP candidates may be equal to thescan order of the constructed affine merge candidates. In addition, inorder to derive the constructed affine MVP candidate, a referencepicture index of a neighboring block may be checked, and, in the scanorder, a first neighboring block inter-coded and referencing the samereference picture as the reference picture of the current block may beused.

Overview of Subblock-Based TMVP (SbTMVP) Mode

Hereinafter, a subblock-based TMVP mode which is an example of an interprediction mode will be described in detail. According to thesubblock-based TMVP mode, a motion vector field (MVF) for a currentblock may be derived and a motion vector may be derived in units ofsubblocks.

Unlike a conventional TMVP mode performed in units of coding units, fora coding unit to which subblock-based TMVP mode applies, a motion vectormay be encoded/decoded in units of sub-coding units. In addition,according to the conventional TMVP mode, a temporal motion vector may bederived from a collocated block, but, in the subblock-based TMVP mode, amotion vector field may be derived from a reference block specified by amotion vector derived from a neighboring block of the current block.Hereinafter, the motion vector derived from the neighboring block may bereferred to as a motion shift or representative motion vector of thecurrent block.

FIG. 19 is a view illustrating neighboring blocks of a subblock basedTMVP mode.

When a subblock-based TMVP mode applies to a current block, aneighboring block for determining a motion shift may be determined. Forexample, scan for the neighboring block for determining the motion shiftmay be performed in order of blocks of A1, B1, B0 and A0 of FIG. 19 . Asanother example, the neighboring block for determining the motion shiftmay be limited to a specific neighboring block of the current block. Forexample, the neighboring block for determining the motion shift mayalways be determined to be a block A1. When a neighboring block has amotion vector referencing a col picture, the corresponding motion vectormay be determined to be a motion shift. The motion vector determined tobe the motion shift may be referred to as a temporal motion vector.Meanwhile, when the above-described motion vector cannot be derived fromneighboring blocks, the motion shift may be set to (0, 0).

FIG. 20 is a view illustrating a method of deriving a motion vectorfield according to a subblock-based TMVP mode.

Next, a reference block on the collocated picture specified by a motionshift may be determined. For example, subblock based motion information(motion vector or reference picture index) may be obtained from a colpicture by adding a motion shift to the coordinates of the currentblock. In the example shown in FIG. 20 , it is assumed that the motionshift is a motion vector of A1 block. By applying the motion shift tothe current block, a subblock in a col picture (col subblock)corresponding to each subblock configuring the current block may bespecified. Thereafter, using motion information of the correspondingsubblock in the col picture (col subblock), motion information of eachsubblock of the current block may be derived. For example, the motioninformation of the corresponding subblock may be obtained from thecenter position of the corresponding subblock. In this case, the centerposition may be a position of a bottom-right sample among four sampleslocated at the center of the corresponding subblock. When the motioninformation of a specific subblock of the col block corresponding to thecurrent block is not available, the motion information of a centersubblock of the col block may be determined to be motion information ofthe corresponding subblock. When the motion vector of the correspondingsubblock is derived, it may be switched to a reference picture index anda motion vector of a current subblock, similarly to the above-describedTMVP process. That is, when a subblock based motion vector is derived,scaling of the motion vector may be performed in consideration of POC ofthe reference picture of the reference block.

As described above, the subblock-based TMVP candidate for the currentblock may be derived using the motion vector field or motion informationof the current block derived based on the subblock.

Hereinafter, a merge candidate list configured in units of subblocks isdefined as a subblock unit merge candidate list. The above-describedaffine merge candidate and subblock-based TMVP candidate may be mergedto configure a subblock unit merge candidate list.

Meanwhile, a subblock-based TMVP mode flag specifying whether asubblock-based TMVP mode is applicable to a current block may bedefined, which may be signaled at least one level among higher levels ofthe current block such as a sequence, a picture, a slice, a tile, a tilegroup, a brick, etc. For example, the subblock-based TMVP mode flag maybe named sps_sbtmvp_enabled_flag. When the subblock-based TMVP mode isapplicable to the current block, the subblock-based TMVP candidate maybe first added to the subblock unit merge candidate list and then theaffine merge candidate may be added to the subblock unit merge candidatelist. Meanwhile, a maximum number of candidates which may be included inthe subblock unit merge candidate list may be signaled. For example, themaximum number of candidates which may be included in the subblock unitmerge candidate list may be 5.

The size of a subblock used to derive the subblock unit merge candidatelist may be signaled or preset to M×N. For example, M×N may be 8×8.Accordingly, only when the size of the current block is 8×8 or greater,an affine mode or a subblock-based TMVP mode is applicable to thecurrent block.

Hereinafter, an embodiment of a prediction performing method of thepresent disclosure will be described. The following predictionperforming method may be performed in step S410 of FIG. 4 or step S630of FIG. 6 .

A predicted block for a current block may be generated based on motioninformation derived according to a prediction mode. The predicted block(prediction block) may include prediction samples (prediction samplearray) of the current block. When the motion vector of the current blockspecifies a fractional sample unit, an interpolation procedure may beperformed and, through this, prediction samples of the current block maybe derived based on reference samples in units of fractional sampleswithin a reference picture. When affine inter prediction applies to thecurrent block, prediction samples may be generated based on asample/subblock unit MV. When bi-prediction applies, prediction samplesderived through a weighted sum or weighted average (according to phase)of prediction samples derived based on L0 prediction (that is,prediction using MVL0 and a reference picture within a reference picturelist L0) and prediction samples derived based on L1 prediction (that is,prediction using MLV1 and a reference picture within a reference picturelist L1) may be used as the prediction samples of the current block.When applying bi-prediction and a reference picture used for L0prediction and the reference picture used for L1 prediction are locatedin different temporal directions with respect to the current picture(that is, if it corresponds to bi-prediction and bi-directionalprediction), this may be called true bi-prediction.

In an image decoding apparatus, reconstructed samples and areconstructed picture may be generated based on the derived predictionsamples and then an in-loop filtering procedure may be performed. Inaddition, in an image encoding apparatus, residual samples may bederived based on the derived prediction samples and encoding of imageinformation including prediction information and residual informationmay be performed.

Bi-Prediction with CU-Level Weight, BCW

When bi-prediction applies to a current block as described above,prediction samples may be derived based on a weighted average.Conventionally, the bi-prediction signal (that is, bi-predictionsamples) was able to be derived through a simple average of an L0prediction signal (L0 prediction samples) and an L1 prediction signal(L1 prediction samples). That is, bi-prediction samples was derivedthrough an average of the L0 prediction samples based on an L0 referencepicture and MVL0 and L1 prediction samples based on an L1 referencepicture and MVL1. However, according to the present disclosure, whenapplying bi-prediction, a bi-prediction signal (bi-prediction samples)may be derived through a weighted average of the L0 prediction signaland the L1 prediction signal as follows.

P _(bi-pred)=((8−w)*P ₀ +w*P ₁+4)>>3  [Equation 3]

In Equation 3 above, P_(bi_pred) denotes a bi-prediction signal(bi-prediction block) derived by a weighted average and P₀ and P₁respectively denote L0 prediction samples (L0 prediction block) and L1prediction samples (L1 prediction block). In addition, (8−w) and wdenote weights applying to P₀ and P₀, respectively.

In generating the bi-prediction signal by the weighted average, fiveweights may be allowed. For example, the weight w may be selected from{−2,3,4,5, 10}. For each bi-predicted CU, the weight w may be determinedby one of two methods. As the first method of the two methods, when acurrent CU is not a merge mode (non-merge CU), a weight index may besignaled along with a motion vector difference. For example, a bitstreammay include information on the weight index after information on themotion vector difference. As the second method of the two methods, whenthe current CU is a merge mode (merge CU), the weight index may bederived from neighboring blocks based on a merge candidate index (mergeindex).

Generation of the bi-prediction signal by the weighted average may belimited to apply to only a CU having a size including 256 or moresamples (luma component samples). That is, bi-prediction by the weightedaverage may be performed only with respect to a CU in which a product ofthe width and height of the current block is 256 or more. In addition,the weight w may be used as one of five weights as described above andone of different numbers of weights may be used. For example, accordingto the characteristics of the current image, five weights may be usedfor a low-delay picture and three weights may be used for anon-low-delay picture. In this case, the three weights may be {3, 4, 5}.

The image encoding apparatus may determine a weight index withoutsignificantly increasing complexity, by applying a fast searchalgorithm. In this case, the fast search algorithm may be summarized asfollows. Hereinafter, an unequal weight may mean that weights applyingto P₀ and P₁ are not equal. In addition, an equal weight may mean thatweights applying to P₀ and P₁ may be equal.

-   -   In the case where an AMVR mode in which resolution of a motion        vector is adaptively changed is applied together, when a current        picture is a low-delay picture, only the unequal weight may be        conditionally checked for each of 1-pel motion vector resolution        and 4-pel motion vector resolution.    -   In the case where an affine mode is applied together and the        affine mode is selected as an optimal mode of the current block,        the image encoding apparatus may perform affine motion        estimation (ME) for each unequal weight.    -   When two reference pictures used for bi-prediction are equal,        only an unequal weight may be conditionally checked.    -   The unequal weight may not be checked when a predetermined        condition is satisfied. The predetermined picture may be based        on a POC distance between a current picture and a reference        picture, a quantization parameter (QP), a temporal level, etc.

A weight index of BCW may be encoded using one context coded bin and oneor more subsequent bypass coded bins. The first context coded binspecifies whether an equal weight is used. When an unequal weight isused, additional bins may be bypass-encoded and signaled. The additionalbins may be signaled to specify which weight is used.

Weighted prediction (WP) is a tool for efficiently encoding an imageincluding fading. According to weighted prediction, weighting parameters(weight and offset) may be signaled for each reference picture includedin each of reference picture lists L0 and L1. Then, when motioncompensation is performed, weight(s) and offset(s) may apply tocorresponding reference picture(s). Weighted prediction and BCW may beused for different types of images. In order to avoid interactionbetween weighted prediction and BCW, a BCW weight index may not besignaled for a CU using weighted prediction. In this case, the weightmay be inferred to be 4. That is, an equal weight may be applied.

In the case of a CU to which a merge mode applies, a weight index may beinferred from neighboring blocks based on a merge candidate index. Thismay apply to both a general merge mode and an inherited affine mergemode.

In the case of a constructed affine merge mode, affine motioninformation may be configured based on motion information of a maximumof three blocks. In this case, the following process may be performed toderive a BCW weight index for a CU using a constructed affine mergemode.

(1) First, the range of the BCW weight index {0, 1, 2, 3, 4} may bedivided into three groups {0}, {1, 2, 3} and {4}. When the BCW weightindex of all CPs are derived from the same group, the BCW weight indexmay be derived by step (2) below. Otherwise, the BCW weight index may beset to 2.

(2) When at least two CPs have the same BCW weight index, the same BCWweight index may be allocated as a weight index of a constructed affinemerge candidate. Otherwise, the weight index of the constructed affinemerge candidate may be set to 2.

Bi-Directional Optical Flow (BDOF)

According to the present disclosure, BDOF may be used to refine abi-prediction signal. BDOF is to generate prediction samples bycalculating refined motion information when bi-prediction applies to acurrent block (e.g., CU). Accordingly, a process of calculating refinedmotion information by applying BDOF may be included in theabove-described motion information derivation step.

For example, BDOF may apply at a 4×4 sub-block level. That is, BDOF maybe performed within the current block in units of 4×4 sub-blocks.

BODF may, for example, apply to a CU satisfying the followingconditions.

1) The height of the CU is not 4 and the size of the CU is not 4×8

2) The CU is not in an affine mode or ATMVP merge mode

3) The CU is encoded in a true bi-prediction mode, that is, one of tworeference pictures precedes a current picture in temporal order and theother follows the current picture in temporal order

In addition, BDOF may apply only to a luma component. However, thepresent disclosure is not limited thereto and BDOF may apply to a chromacomponent or both a luma component and a chroma component.

A BDOF mode is based on the concept of optical flow. That is, it isassumed that motion of an object is smooth. When applying BDOF, for each4×4 sub-block, a motion refinement (v_(x), v_(y)) may be calculated. Themotion refinement may be calculated by minimizing a difference betweenan L0 prediction sample and an L1 prediction sample. The motionrefinement may be used to adjust bi-predicted sample values within a 4×4sub-block.

Hereinafter, a process of performing BDOF will be described in greaterdetail.

First, horizontal gradients

$\frac{\partial I^{(k)}}{\partial x}( {i,j} )$

and vertical gradients

$\frac{\partial I^{(k)}}{\partial y}( {i,j} )$

of two prediction signals may be calculated. In this case, k may be 0or 1. The gradients may be calculated as shown in Equation 4 below bydirectly calculating a difference between two adjacent samples.

$\begin{matrix}{{\frac{\partial I^{(k)}}{\partial x}( {i,j} )} = {( {{I^{(k)}( {{i + 1},j} )} - {I^{(k)}( {{i - 1},j} )}} ) \gg 4}} & \lbrack {{Equation}4} \rbrack\end{matrix}$${\frac{\partial I^{(k)}}{\partial y}( {i,j} )} = {( {{I^{(k)}( {i,{j + 1}} )} - {I^{(k)}( {i,{j - 1}} )}} ) \gg 4}$

In Equation 4 above, I^((k))(i, j) denotes a sample value of coordinates(i, j) of a prediction signal in a list k (k=0, 1). For example, I⁽⁰⁾(i,j) may denote a sample value at a position (i, j) in an L0 predictionblock, and I⁽¹⁾(i, j) may denote a sample value at a position (i, j) inan L1 prediction block.

In Equation 4 above, a difference between two samples is right-shiftedby 4. However, the present disclosure is not limited thereto and theright shift shift1 may be determined based on a bit depth of a lumacomponent. For example, when the bit depth of the luma component isbitDepth, shift1 may be determined to be max(6, bitDepth−6) or maysimply be determined to be a fixed value of 6. In Equation 4 above, forgradient calculation, a difference between two samples was firstcalculated and then right shift operation applied to the difference.However, the present disclosure is not limited thereto and the gradientsmay be calculated by applying right shift operation to two sample valuesand then calculating a difference between right-shifted values.

As described above, after calculating the gradients, auto-correlationand cross-correlation S₁, S₂, S₃, S₅ and S₆ between the gradients may becalculated as follows

$\begin{matrix}{{S_{1} = {\Sigma_{{({i,j})} \in \Omega}{{\psi_{x}( {i,j} )} \cdot {\psi_{x}( {i,j} )}}}},} & \lbrack {{Equation}5} \rbrack\end{matrix}$ S₂ = Σ_((i, j) ∈ Ω)ψ_(x)(i, j) ⋅ ψ_(y)(i, j)S₃ = Σ_((i, j) ∈ Ω)θ(i, j) ⋅ ψ_(x)(i, j)S₅ = Σ_((i, j) ∈ Ω)ψ_(y)(i, j) ⋅ ψ_(y)(i, j)S₆ = Σ_((i, j) ∈ Ω)θ(i, j) ⋅ ψ_(y)(i, j) where${\psi_{x}( {i,j} )} = {( {{\frac{\partial I^{(1)}}{\partial x}( {i,j} )} + {\frac{\partial I^{(0)}}{\partial x}( {i,j} )}} ) \gg n_{a}}$${\psi_{y}( {i,j} )} = {( {{\frac{\partial I^{(1)}}{\partial y}( {i,j} )} + {\frac{\partial I^{(0)}}{\partial y}( {i,j} )}} ) \gg n_{a}}$θ(i, j) = (I⁽¹⁾(i, j) ≫ n_(b)) − (I⁽⁰⁾(i, j) ≫ n_(b))

where Ω is a 6×6 window around the 4×4 sub-block.

The motion refinement (v_(x), v_(y)) may be derived as follows using theabove-described auto-correlation and cross-correlation between thegradients.

$\begin{matrix}{v_{x} = {S_{1} > {{0?{clip}}3( {{- {th}_{BIO}^{\prime}},{th}_{BIO}^{\prime},{- ( {( {S_{3} \cdot 2^{n_{b} - n_{a}}} ) \gg \lfloor {\log_{2}S_{1}} \rfloor} )}} ):0}}} & \lbrack {{Equation}6} \rbrack\end{matrix}$v_(y) = S₅ > 0?clip3(−th_(BIO)^(′), th_(BIO)^(′), −((S₆ ⋅ 2^(n_(b) − n_(a)) −  ((v_(x)S_(2, m)) ≪ n_(S₂) + v_(x)S_(2, s))/2) ≫ ⌊log₂S₅⌋)) : 0

where S_(2,m)=S₂>>n_(s) ₂ , S_(2,s)=S₂&(2^(n) ^(s2) −1),th′_(BIO)=2^(13-BD) and └⋅┘ is the floor function.

Based on the derived motion refinement and gradients, the followingadjustment may be performed with respect to each sample in the 4×4sub-block.

$\begin{matrix}{{b( {x,y} )} = {{{rnd}( {( {v_{x}( {\frac{\partial{I^{(1)}( {x,y} )}}{\partial x} - \frac{\partial{I^{(0)}( {x,y} )}}{\partial x}} )} )/2} )} + {{rnd}( {( {v_{y}( {\frac{\partial{I^{(1)}( {x,y} )}}{\partial y} - \frac{\partial{I^{(0)}( {x,y} )}}{\partial y}} )} )/2} )}}} & \lbrack {{Equation}7} \rbrack\end{matrix}$

Finally, prediction samples pred_(BDOF) of a CU, to which BDOF applies,may be calculated by adjusting the bi-prediction samples of the CU asfollows.

pred_(BDOF)(x,y)=)(I ⁽⁰⁾(x,y)+I ⁽¹⁾(x,y)+b(x,y)+o_(offset))>>shift  [Equation 8]

In above Equations, n_(a), n_(b) and n_(S2) may be 3, 6 and 12,respectively. These values may be selected such that a multiplier doesnot exceed 15 bits in the BDOF process and bit-widths of intermediateparameters are maintained within 32 bits.

In order to derive a gradient value, prediction samples I^((k))(i, j) ina list k (k=0, 1) existing outside a current CU may be generated. FIG.21 is a view illustrating a CU extended to perform BDOF.

As shown in FIG. 21 , in order to perform BDOF, rows/columns extendingaround the boundary of a CU may be used. In order to controlcomputational complexity for generating prediction samples outside theboundary, prediction samples in an extended region (white region in FIG.21 ) may be generated using a bilinear filter, and prediction samples ina CU (gray region in FIG. 21 ) may be generated using a normal 8-tapmotion compensation interpolation filter. The sample values at theextended positions may be used only for gradient calculation. Whensample values and/or gradient values located outside the CU boundary arerequired to perform the remaining steps of the BDOF process, nearestneighboring sample values and/or gradient values may be padded(repeated) and used.

When the width and/or height of the CU are greater than 16 luma samples,the corresponding CU may be split into sub-blocks having a width and/orheight of 16 luma samples. The boundary of the sub-blocks may be treatedin the same manner as the above-described CU boundary in the BDOFprocess. A maximum unit size in which the BDOF process is performed maybe limited to 16×16.

When BCW is available for a current block, for example, when a BCWweight index specifies an unequal weight, BDOF may not apply. Similarly,when WP is available for the current block, for example, whenluma_weight_1x_flag for at least one of two reference pictures is 1,BDOF may not apply. In this case, luma_weight_1x_flag may be informationspecifying whether weighting factors of WP for a luma component of 1xprediction (x being 0 or 1) is present in a bitstream or informationspecifying whether WP applies to a luma component of 1x prediction. Whenthe CU is encoded in an SMVD mode, BDOF may not apply.

Prediction Refinement with Optical Flow (PROF)

Hereinafter, a method of refining a sub-block based affine motioncompensation-predicted block by applying optical flow will be described.Prediction samples generated by performing sub-block based affine motioncompensation may be refined based on a difference derived by an opticalflow equation. Refinement of such prediction samples may be calledprediction refinement with optical flow (PROF) in the presentdisclosure. By PROF, inter prediction of pixel level granularity may beachieved without increasing bandwidth of memory access.

Parameters of an affine motion model may be used to derive a motionvector of each pixel in a CU. However, since pixel based affine motioncompensation prediction causes high complexity and an increase inbandwidth of memory access, sub-block based affine motion compensationprediction may be performed. When sub-block based affine motioncompensation prediction is performed, the CU may be split into 4×4sub-blocks and a motion vector may be determined for each sub-block. Inthis case, the motion vector of each sub-block may be derived from CPMVsof the CU. Sub-block based affine motion compensation has a trad-offrelationship between encoding efficiency and complexity and bandwidth ofmemory access. Since a motion vector is derived in units of sub-blocks,complexity and bandwidth of memory access are reduced but predictionaccuracy is lowered.

Accordingly, motion compensation of refined granularity may be achievedthrough refinement by applying optical flow to sub-block based affinemotion compensation prediction.

As described above, luma prediction samples may be refined by adding adifference derived by an optical flow equation after performingsub-block based affine motion compensation. More specifically, PROF maybe performed in the following four steps.

Step 1) A predicted sub-block I(i, j) is generated by performingsub-block based affine motion compensation.

Step 2) Spatial gradients g_(x)(i, j) and g_(y)(i, j) of the predictedsub-block is calculated at each sample position. In this case, a 3-tapfilter may be used, and filter coefficient may be [−1, 0, 1]. Forexample, the spatial gradients may be calculated as follows.

g _(x)(i,j)=I(i+1,j)−I(i−1,j)

g _(y)(i,j)=I(i,j+1)−I(i,j−1)  [Equation 9]

To calculate the gradients, predicted sub-blocks may extend by one pixelon each side. In this case, to lower memory bandwidth and complexity,pixels of extended boundaries may be copied from closest integer pixelsin a reference picture. Accordingly, additional interpolation for apadding region may be skipped.

Step 3) Luma prediction refinement (ΔI(i, j)) may be calculated by anoptical flow equation. For example, the following equation may be used.

ΔI(i,j)=g _(x)(i,j)*Δv _(x)(i,j)+g _(y)(i,j)*Δv _(y)(i,j)  [Equation 10]

In the above equation, Δv(i, j) denotes a difference between a pixelmotion vector (pixel MV, v(i, j)) calculated at a sample position (i, j)and a sub-block MV of a sub-block, to which a sample (i, j) belongs.

FIG. 22 is a view illustrating a relationship among Δv(i, j), v(i, j)and a sub-block motion vector.

In the example shown in FIG. 22 , for example, a difference between amotion vector v(i, j) at a top-left sample position of a currentsub-block and a motion vector v_(SB) of the current sub-block may berepresented by a thick dotted arrow, and a vector represented by thethick dotted arrow may correspond to Δv(i, j).

Affine model parameters and pixel positions from the center of thesub-block are not changed. Accordingly, Δv(i, j) may be calculated onlyfor a first sub-block and may be reused for the other sub-blocks in thesame CU. Assuming that a horizontal offset and a vertical offset fromthe pixel position to the center of the sub-block are respectively x andy, Δv(x, y) may be derived as follows.

$\begin{matrix}\{ \begin{matrix}{{\Delta{v_{x}( {x,y} )}} = {{c*x} + {d*y}}} \\{{\Delta{v_{y}( {x,y} )}} = {{e*x} + {f*y}}}\end{matrix}  & \lbrack {{Equation}11} \rbrack\end{matrix}$

For 4-parameter affine model,

$\{ \begin{matrix}{c = {f = \frac{v_{1x} - v_{0x}}{w}}} \\{e = {{- d} = \frac{v_{1y} - v_{0y}}{w}}}\end{matrix} $

For 6-parameter affine model,

$\{ \begin{matrix}\begin{matrix}\begin{matrix}{c = \frac{v_{1x} - v_{0x}}{w}} \\{d = \frac{v_{2x} - v_{0x}}{h}}\end{matrix} \\{e = \frac{v_{1y} - v_{0y}}{w}}\end{matrix} \\{f = \frac{v_{2y} - v_{0y}}{h}}\end{matrix} $

In the above, (v_(0x), v_(0y)), (v_(1x), v_(1y)) and (v_(2x), v_(2y))respectively correspond to a top-left CPMV, a top-right CPMV and abottom-left CPMV, and w and h respectively denote the width and heightof the CU.

Step 4) Finally, a final prediction block I′(i, j) may be generatedbased on the calculated luma prediction refinement ΔI(i, j) and thepredicted sub-block I(i, j). For example, a final prediction block I′may be generated as follows.

I′(i,j)=I(i,j)++ΔI(i,j)  [Equation 12]

As described above, by applying BDOF in an inter prediction process torefine a reference sample in a motion compensation process, it ispossible to increase compression performance of an image. BDOF may beperformed in a normal mode. That is, BDOF is not performed in case of anaffine mode, a GPM mode or a CIIP mode.

PROF may be performed on a block encoded in an affine mode, as a methodsimilar to BDOF. As described above, by refining a reference sample ineach 4×4 sub-block through PROF, it is possible to increase compressionperformance of an image.

The present disclosure proposes various methods capable of preventingpotential errors of PROF and improving performance by applyingnormalization and clipping when deriving a PROF offset (refinement ΔI ordI) for refinement of a reference sample in a PROF process. In thepresent disclosure, normalization may mean that values expressed invarious units (e.g., 1/64-pel, 1/32-pel, 2-pel, etc.) are unified into avalue in a predetermined unit (e.g., 1-pel). In addition, in the presentdisclosure, [a, b] may mean a range of values of a to b, and clipping acertain value x in a range of [a, b] may mean that the range of x islimited to have a value of a when x is less than a, a value of b when xis greater than b and a value of x in the other case. In addition, inthe present disclosure, a bit depth is not limited to a bit depth of aluma component, and may include, for example, a bit depth when bitdepths of a luma component and a chroma component are the same.

According to embodiments of the present disclosure, the above-describedaffine motion (subblock motion) information of the current block may bederived, and affine motion information may be refined through theabove-described PROF process or a prediction sample derived based onaffine motion information may be refined.

FIG. 23 is a view illustrating a process of deriving a prediction sampleof a current block by applying PROF.

The PROF based inter prediction procedure of FIG. 23 may be performed byan image encoding apparatus and an image decoding apparatus.

First, in step S2310, motion information of a current block may bederived. The motion information of the current block may be derived byvarious methods described in the present disclosure. For example, themotion information of the current block may be derived by the methoddescribed in the above-described affine mode or sub-block based TMVPmode. The motion information may include subblock motion information ofthe current block. The subblock motion information may includebi-prediction subblock motion information (L0 subblock motioninformation and L1 subblock motion information). For example, the L0subblock motion information may include sbMVL0 (L0 subblock motionvector) and refIdxL0 (L0 reference picture index), and L1 subblockmotion information may include sbMVL1 (L1 subblock motion vector) andrefIdxL1 (L1 reference picture index).

Thereafter, a prediction sample of the current block may be derivedbased on the derived motion information of the current block (S2320).Specifically, L0 prediction samples for each subblock of the currentblock may be derived based on the L0 subblock motion information. Inaddition, L1 prediction samples for each subblock of the current blockmay be derived based on the L1 subblock motion information.

Thereafter, a PROF offset may be derived based on the derived predictionsamples (S2330). PROF of step S2330 may be performed according to themethod described in the present disclosure. For example, a differencemotion vector diffMv and gradients of LX (X=0 or 1) prediction samplesmay be calculated and, based on these, a PROF offset dI or ΔI may bederived according to the method described in the present disclosure.Various examples of the present disclosure relate to difference motionvector derivation, gradient derivation and/or PROF offset derivation.

Thereafter, based on the LX (X=0 or 1) prediction samples and the PROFoffset, refined prediction samples of the current block may be derived(S2340). The refined prediction samples may be used to generate a finalprediction block of the current block. For example, the final predictionblock of the current block may be generated by weighted-summing therefined L0 prediction samples and the refined L1 prediction samples.

The image encoding apparatus may derive residual samples throughcomparison with original samples based on the prediction samples of thecurrent block generated according to the method of FIG. 23 . Information(residual information) on the residual samples may be included andencoded in image/video information and output in the form of a bitstreamas described above. In addition, the image decoding apparatus maygenerate a reconstructed current block based on the prediction samplesof the current block generated according to the method of FIG. 23 andthe residual samples obtained based on residual information in abitstream, as described above.

FIG. 24 is a view illustrating an example of a PROF process according tothe present disclosure.

According to the example of FIG. 24 , the PROF process may be performedusing a width sbWidth, a height sbHeight of a current subblock, aprediction subblock predSamples in which a border area extends by apredetermined length borderExtention and a difference motion vectordiffMv as input. In this case, the prediction subblock may be, forexample, a prediction subblock generated by performing affine motioncompensation. As a result of performing the PROF process, a refinedprediction subblock pbSamples may be generated.

In order to perform the PROF process, a predetermined first shift shift1may be calculated. The first shift may be derived based on a bit depthBitDepth_(Y) of a luma component. For example, the first shift may bederived as a maximum value of 6 and (BitDepth_(Y)−6).

Thereafter, a horizontal gradient gradientH, g_(x) and a verticalgradient gradientV, g_(y) may be calculated for each sample position (x,y) of the input prediction subblock. The horizontal gradient and thevertical gradient may be calculated according to Equation (1) andEquation (2) of FIG. 24 , respectively.

Thereafter, based on the horizontal gradient, the vertical gradient andthe difference motion vector diffMv, the PROF offset dI or ΔI for eachsample position may be calculated. For example, the PROF offset may becalculated according to Equation (3) of FIG. 24 . In Equation (3), thedifference motion vector diffMv used to calculate the PROF offset maymean Av described with reference to FIG. 22 . In this case, diffMv maybe clipped by dmvLimit as follows, and dmvLimit may be calculated basedon BitDepth_(Y) as follows.

dmvLimit=1<<Max(5,BitDepthY−7),diffMv[x][y][i]=Clip3(dmvLimit,dmvLimit−1,diffMv[x][y][i])  [Equation13]

Thereafter, a refined prediction subblock pbSamples may be derived basedon the calculated PROF offset and the prediction subblock predSamples.For example, the refined prediction subblock may be derived according toEquation (4) of FIG. 24 .

According to an example of FIG. 24 , bit widths of predSample and eachparameter of PROF according to BitDepth_(Y) may be derived as shown inthe following table.

TABLE 1 BitDepth_(Y) predSample Shift1 Gradient diffMv dI 8 16 6 11 6 17[−25022, [−779,779] [−32, 31] [−49856, 24958] 48298] 10 16 6 11 6 17 1216 6 11 6 17 14 18 8 11 8 19 16 20 10 11 10 21

In Table 1 above, for example, when BitDepth_(Y) is 8, predSample has avalue of a 16-bit range, the gradient uses 11 bits, diffMv uses 6 bits,and the range of the dI value is [−49856, 48298]. As shown in Table 1above, as BitDepth_(Y) is changed, the bit width of predSample ischanged. However, a gradient having high association with BitDepth_(Y)has a fixed bit width (11 bits) even when BitDepth_(Y) is changed. Inaddition, the bit width of diffMv which is not associated withBitDepth_(Y) is changed as BitDepth_(Y) is changed.

According to the below-described embodiments of the present disclosure,by refining normalization and clipping of parameters used in the PROFprocess, association with the parameters and BitDepth_(Y) may be moreaccurately reflected. Accordingly, the parameters may have more accuratevalues and memory overflow issues in the PROF process may be solved.

FIG. 25 is a view illustrating a refined PROF process according to anembodiment of the present disclosure.

Input and output of the PROF process of FIG. 25 are respectively equalto those of the PROF process of FIG. 24 and thus a detailed descriptionthereof will be omitted. According to FIG. 25 , a first shift shift1 forperforming the PROF process may be set to a fixed value regardless ofthe bit depth. For example, the first shift may be set to 6. Thereafter,the horizontal gradient and the vertical gradient may be calculatedaccording to Equation (1) and Equation (2) of FIG. 25 and the PROFoffset may be calculated according to Equation (3). Thereafter, therefined prediction subblock may be derived according to Equation (4) ofFIG. 25 .

FIG. 26 is a view illustrating a refined diffMv derivation processaccording to an embodiment of the present disclosure.

According to the example of FIG. 26 , when cbProfFlagLX is 1, that is,upon determining that PROF applies, diffMv may be derived. In this case,dmvLimit for clipping diffMv may be set to a fixed value regardless ofthe bit depth. For example, according to Equation (3) of FIG. 26 ,dmvLimit may be set to “1<<5”.

In the embodiments disclosed in FIGS. 25 and 26 , the horizontalgradient and the vertical gradient represent the slopes at a 2-pixeldistance in the horizontal and vertical direction of the current sampleposition. In addition, when diffMv is 1/32-pel precision and has a rangeof values of [−32, 31] or [−32, 32], a value of 1 of diffMv representsan actual 1/32-pel distance. Accordingly, diffMv may be seen as applying“1<<5” operation to a 1-pixel unit value.

According to the embodiments disclosed in FIGS. 25 and 26 , parameters(the horizontal gradient, the vertical gradient, diffMv) used tocalculate the PROF offset may be normalized to a 1-pixel unit value. Forexample, for a gradient which is a slope of a 2-pixel distance,normalization may be performed to a 1-pixel unit value by applying “>>1”operation. In addition, for diffMv of 1/32-pel precision, normalizationmay be performed to a 1-pixel unit value by applying “>>5” operation. Inconsideration of this, as shown in Equation (3) of FIG. 25 , “>>6”operation may apply to a value obtained by multiplying the gradient bydiffMv for normalization. That is, according to the embodimentsdisclosed in FIGS. 25 and 26 , the first shift may be set to a fixedvalue without considering the bit depth, and normalization may beperformed to a 1-pixel unit value in consideration of the gradient anddiffMv together. In addition, dmvLimit representing the clipping rangeof the diffMv value may be set to a fixed value without considering thebit depth.

According to the examples of FIGS. 25 and 26 , bit widths of predSampleand each parameter of PROF according to BitDepth_(Y) may be changed asshown in the following table.

TABLE 2 BitDepth_(Y) predSample Shift1 Gradient diffMv dI 8 16 6 17 6 17[−25022, [−49980, [−32, 31] [−49980, 24958] 49980] 49980] 10 16 6 17 617 12 16 6 17 6 17 14 18 6 19 6 19 16 20 6 21 6 21

As shown in Table 2 above, the gradient having high association with thebit depth is changed according to the bit depth. In addition, since therange of the gradient value is determined based on the predSample value,accuracy of the gradient value may increase. In addition, the bit widthof diffMv which is not associated with the bit depth may have a fixedvalue regardless of the bit depth. According to Table 2, instead ofincreasing the range of the gradient value, since the range of the valueof diffMv decreases, it may not affect the range of the dI value.

FIG. 27 is a view illustrating a refined PROF process according toanother embodiment of the present disclosure.

Input and output of the PROF process of FIG. 27 are respectively equalto those of the PROF process of FIG. 24 and thus a detailed descriptionthereof will be omitted. According to FIG. 27 , a first shift shift1 forperforming the PROF process may be set to a fixed value regardless ofthe bit depth. For example, the first shift may be set to 5. Thereafter,the horizontal gradient and the vertical gradient may be calculatedaccording to Equation (1) and Equation (2) of FIG. 27 and the PROFoffset may be calculated according to Equation (3). Thereafter, therefined prediction subblock may be derived according to Equation (4) ofFIG. 27 . In this case, diffMv may be, for example, derived according tothe method disclosed in FIG. 26 .

As described above in the embodiment of FIG. 25 , the gradient anddiffMv may be normalized to a 1-pixel unit value. However, according tothe embodiment of FIG. 25 , bit overflow may be generated in thegradient calculation process. According to the embodiment of FIG. 27 ,bit overflow in the gradient calculation process may be prevented. Forexample, as shown in Equation (1) and Equation (2) of FIG. 25 , whenshift operation is not performed in the gradient calculation process,32-bit operation may be performed to calculate the gradient. That is,bit overflow may be generated when calculating the gradient. In theembodiment of FIG. 27 , in consideration of this, as shown in Equation(1) and Equation (2) of FIG. 27 , normalization for the gradient mayapply when calculating the gradient.

According to the embodiment disclosed in FIG. 27 , normalization may beperformed by applying “>>1” operation when calculating the gradient,thereby preventing bit overflow. According to the example of FIG. 27 ,the gradient may not exceed 16 bits. Meanwhile, normalization for diffMvmay be performed by Equation (3), and, for this, the first shift may beset to a fixed value without considering the bit depth. For example, thefirst shift may be set to 5.

According to the example of FIG. 27 , bit widths of predSample and eachparameter of PROF according to BitDepth_(Y) may be changed as shown inthe following table.

TABLE 3 BitDepth_(Y) predSample Shift1 Gradient diffMv dI 8 16 5 16 6 17[−25022, [−24990, [−32, 31] [−49980, 24958] 24990] 49980] 10 16 5 16 617 12 16 5 16 6 17 14 18 5 18 6 19 16 20 5 20 6 21

As shown in Table 3 above, the gradient having high association with thebit depth is changed according to the bit depth. In addition, byperforming shift operation in Equation (1) and Equation (2) of FIG. 27 ,bit overflow when calculating the gradient may be prevented. Inaddition, the bit width of diffMv which is not associated with the bitdepth may have a fixed value regardless of the bit depth.

FIG. 28 is a view illustrating a refined PROF process according toanother embodiment of the present disclosure.

Input and output of the PROF process of FIG. 28 are respectively equalto those of the PROF process of FIG. 24 and thus a detailed descriptionthereof will be omitted. According to FIG. 28 , a first shift shift1 forperforming the PROF process may be set to a fixed value regardless ofthe bit depth. For example, the first shift may be set to 6. Thereafter,the horizontal gradient and the vertical gradient may be calculatedaccording to Equation (1) and Equation (2) of FIG. 28 and the PROFoffset may be calculated according to Equation (3). Thereafter, therefined prediction subblock may be derived according to Equation (4) ofFIG. 28 . In this case, diffMv may be, for example, derived according tothe method disclosed in FIG. 26 .

As described above in the embodiment of FIG. 25 , the gradient anddiffMv may be normalized to a 1-pixel unit value. However, according tothe embodiment of FIG. 25 , as described above, bit overflow may begenerated in the gradient calculation process. In the embodiment of FIG.28 , in consideration of this, as shown in Equation (1) and Equation (2)of FIG. 28 , right shift operation may be performed when calculating thegradient. According to the embodiment disclosed in FIG. 28 , whencalculating the gradient, bit overflow may be prevented by applying“>>shift1” operation. According to the example of FIG. 28 , the gradientmay not exceed 16 bits.

According to the example of FIG. 28 , bit widths of predSample and eachparameter of PROF according to BitDepth_(Y) may be changed as shown inthe following table.

TABLE 4 BitDepth_(Y) predSample Shift1 Gradient diffMv dI 8 16 6 11 6 17[−25022, [−779,779] [−32, 31] [−49856, 24958] 48298] 10 16 6 11 6 17 1216 6 11 6 17 14 18 6 13 6 19 16 20 6 15 6 21

As shown in Table 4 above, the gradient having high association with thebit depth is changed according to the bit depth. In addition, byperforming shift operation in Equation (1) and Equation (2) of FIG. 28 ,bit overflow when calculating the gradient may be prevented. Inaddition, the bit width of diffMv which is not associated with the bitdepth may have a fixed value regardless of the bit depth.

FIG. 29 is a view illustrating a refined PROF process according toanother embodiment of the present disclosure.

Input and output of the PROF process of FIG. 29 are respectively equalto those of the PROF process of FIG. 24 and thus a detailed descriptionthereof will be omitted. According to FIG. 29 , a first shift shift1 forperforming the PROF process may be set to a fixed value regardless ofthe bit depth. For example, the first shift may be set to 6. Inaddition, clipping may be performed such that bit overflow is notgenerated when calculating the gradient, and gradLimit specifying theclipping range of the gradient may be set. gradLimit maybe set so thatthe gradient does not exceed 16 bits. For example, gradLimit may be setto “1<<Max(15, BitDepth+3)”. Thereafter, the horizontal gradient and thevertical gradient may be calculated according to Equation (1) andEquation (2) of FIG. 29 , and the PROF offset may be calculatedaccording to Equation (3). Thereafter, the refined prediction subblockmay be derived according to Equation (4) of FIG. 29 . In this case,diffMv may be, for example, derived according to the method disclosed inFIG. 26 .

As described above in the embodiment of FIG. 25 , the gradient anddiffMv may be normalized to a 1-pixel unit value. However, according tothe embodiment of FIG. 25 , as described above, bit overflow may begenerated in the gradient calculation process. According to theembodiment of FIG. 29 , bit overflow in the gradient calculation processmay be prevented. For example, as shown in Equation (1) and Equation (2)of FIG. 29 , bit overflow may be prevented by performing clippingoperation in the gradient calculation process.

As described above in the example of FIG. 25 , for the gradient,normalization may be performed to a 1-pixel unit value by applying “>>1”operation, and, for diffMv, normalization may be performed to a 1-pixelunit value by applying “>>5” operation. According to the embodiment ofFIG. 29 , as shown in Equation (3) of FIG. 29 , for normalization, “>>6”operation may apply to a value obtained by multiplying the gradient bydiffMv. That is, according to the embodiments disclosed in FIG. 29 , thefirst shift may be set to a fixed value without considering the bitdepth, and normalization may be performed to a 1-pixel unit value inconsideration of the gradient and diffMv together. In addition, in orderto prevent bit overflow, clipping operation may be performed in thegradient calculation process.

According to the example of FIG. 29 , bit widths of predSample and eachparameter of PROF according to BitDepth_(Y) may be changed as shown inthe following table.

TABLE 5 BitDepth_(Y) predSample Shift1 Gradient diffMv dI 8 16 6 16 6 17[−25022, [−24990, [−32, 31] [−49980, 24958] 24990] 49980] 10 16 6 16 617 12 16 6 16 6 17 14 18 6 18 6 19 16 20 6 20 6 21

As shown in Table 5 above, the gradient having high association with thebit depth is changed according to the bit depth. In addition, byperforming clipping operation in Equation (1) and Equation (2) of FIG. 9, bit overflow when calculating the gradient may be prevented. Inaddition, the bit width of diffMv which is not associated with the bitdepth may have a fixed value regardless of the bit depth.

Hereinafter, a refined diffMv derivation process according to thepresent disclosure will be described.

FIG. 30 is a view illustrating a refined diffMv derivation processaccording to another embodiment of the present disclosure.

According to the example of FIG. 30 , when cbProfFlagLX is 1, diffMv maybe derived. In this case, dmvLimit for clipping diffMv may be set to afixed value regardless of the bit depth. For example, according toEquation (3) of FIG. 30 , dmvLimit may be set to “1<<5”. In addition, aright shift rightShift in a rounding process of diffMv may be adjustedsuch that diffMv is 1/32-pel precision and has a range of values of[−32, 31] or [−32, 32]. For example, as the right shift, a value of 6may be used instead of 7. diffMv may be used to calculate the PROFoffset as described above. Accordingly, right shift operation which willapply to the PROF offset may apply to calculation of diffMv. Inconsideration of this, for example, a value of 8 may be used as theright shift in the rounding process of diffMv. In the presentdisclosure, the rounding process of diffMv may be a process of inputtingdiffMv and the right shift rightShift and outputting rounded diffMvgenerated by right-shifting the input diffMv by rightShift.

According to the embodiments of the present disclosure, diffMv may beclipped in a range of [−dmvLimit, dmvLimit−1]. That is, the absolutevalue of a minimum value and the absolute value of a maximum value ofthe clipping range of diffMv are different. In the above-describedembodiments of the present disclosure, modification may be made suchthat the absolute value of the minimum value and the absolute value ofthe maximum value of the clipping range of diffMv are equal. Forexample, diffMv may be modified to be clipped in a range of [−dmvLimit,dmvLimit] or to be clipped in a range of [−dmvLimit+1, dmvLimit−1].Accordingly, the value of diffMv according to the present disclosure maybe included in various ranges of [−16, 15], [−16, 16], [−15, 15], [−32,31], [−32, 32], [−31, 31], [−64, 63], [−64, 64], [−63, 63], [−128, 127],[−128, 128] or [−127, 127] at 1/32-pel precision or 1/64-pel precision.

FIG. 31 is a view illustrating a refined diffMv derivation processaccording to another embodiment of the present disclosure.

According to the example of FIG. 31 , when cbProfFlagLX is 1, diffMv maybe derived. In this case, dmvLimit for clipping diffMv may be set to afixed value regardless of the bit depth. For example, according toEquation (3) of FIG. 31 , dmvLimit may be set to “1<<5”. In addition, asdescribed above, the right shift in the rounding process of diffMv maybe set to a value of 8 in consideration of right shift operation whichwill apply to the PROF offset.

In addition, the clipping range of diffMv may be set such that theabsolute value of the minimum value and the absolute value of themaximum value of the clipping range of diffMv are equal. For example, asshown in Equation (8) of FIG. 31 , diffMv may be clipped in a range of[−dmvLimit+1, dmvLimit−1].

FIG. 32 is a view illustrating a refined diffMv derivation processaccording to another embodiment of the present disclosure.

According to the example of FIG. 32 , when cbProfFlagLX is 1, diffMv maybe derived. In this case, when an affine mode applies to a current blockto limit the range of a value of CPMV, clipping of diffMv may not beperformed. Accordingly, according to the example of FIG. 32 , dmvLimitfor clipping diffMv may not be set and the process of clipping diffMvmay be omitted.

According to the refined diffMv derivation process according to thepresent disclosure, diffMv may be limited to a value of a predeterminedrange without considering the bit depth.

Hereinafter, modified examples of embodiments of the present disclosurewhen diffMv has 1/64-pel precision will be described.

For example, when diffMv has 1/64-pel precision, in the embodimentdisclosed in FIG. 25 , the first shift may be changed to 7. That is,“>>1” operation may apply for normalization of the gradient and “>>6”operation may apply for normalization of diffMv of 1/64-pel precision.Accordingly, “>>7” operation may apply to a value obtained bymultiplying the gradient by diffMv for normalization.

For example, when diffMv has 1/64-pel precision, in the embodimentdisclosed in FIG. 27 , the first shift may be changed to 6. That is, inorder to prevent bit overflow, when calculating the gradient,normalization of the gradient may be performed by applying “>>1”operation. Meanwhile, “>>6” operation may apply to a value obtained bymultiplying the gradient by diffMv for normalization of diffMv of1/64-pel precision.

For example, when diffMv has 1/64-pel precision, in the embodimentdisclosed in FIG. 28 , the first shift may be changed to 7. That is, inorder to prevent bit overflow, “>>shift1” operation may apply whencalculating the gradient. Alternatively, in the embodiment disclosed inFIG. 28 , instead of changing the first shift, “>>1” operation may applyto the PROF offset dI. That is, in Equation (4) of FIG. 28 , dI may bereplaced with (dI+1)>>1.

For example, when diffMv has 1/64-pel precision, in the embodimentdisclosed in FIG. 29 , the first shift may be changed to 7. That is,“>>1” operation may apply for the normalization of the gradient and“>>6” operation may apply for normalization of diffMv of 1/64-pelprecision. Accordingly, “>>7” operation may apply to a value obtained bymultiplying the gradient by diffMv for normalization.

Hereinafter, an embodiment of clipping a PROF offset according to thepresent disclosure will be described.

A prediction sample predSample generated by interpolation of interprediction has a range of values determined by an input bit depth and acoefficient of an interpolation filter, and, in the worst case, has arange of values of [−16830, 33150]. In this case, by adding a value of−8192 to the predSample value in order to prevent 16-bit overflow, asshown in Table 1, the value of predSample may be adjusted to the rangeof [−25022, 24958].

Accordingly, as shown in Table 1, when BitDepth_(Y) is 8, predSample hasa value of a 16-bit range, the gradient uses 11 bits, diffMv and uses 6bits, and eventually the range of the dI is [−49856, 48298].Accordingly, according to various embodiments of the present disclosure,when predSample and dI are added, 16-bit overflow may be generated.

According to the present disclosure, when the value of the refinedprediction sample is calculated by clipping the PROF offset (dI) valuein a predetermined range, 16-bit overflow may be prevented from beinggenerated. More specifically, predSample has a value of a 16-bit rangewhen the bit depth is 8 to 12 and predSample has a value of an 18-bitrange and 20-bit range when the bit depth is 14 and 16. Accordingly, theclipping range of dI may also be defined in consideration of the bitdepth. For example, a variable dILimit specifying the clipping range ofdI may be defined based on the bit depth, and clipping of dI mayadditionally apply to the embodiments of the present disclosure.

For example, in the embodiment disclosed in FIG. 24 , ((dI+1)>>1) ofEquation (4) may be clipped in a range of [−dILimit, dILimit−1]. In thiscase, dILimit may be defined based on the bit depth. For example,dILimit may be set to “1<<Max(12, BitDepth_(Y))”.

For example, in the embodiment disclosed in FIGS. 25, 27, 28 and 29 , dIof Equation (4) may be clipped in a range of [−dILimit, dILimit−1]. Inthis case, dILimit may be defined based on the bit depth. For example,dILimit may be set to “1<<Max(12, BitDepth_(Y))”.

According to another embodiment of the present disclosure, an embodimentof clipping the above-described PROF offset may be modified and appliedas follows.

A prediction sample predSample generated by interpolation of interprediction has a range of values determined by an input bit depth and acoefficient of an interpolation filter, and, when the current block ispredicted in an affine mode, since a 6-tap interpolation filter appliesand, in the worst case, has a range of values of [−14066, 27509]. Inthis case, by adding a value of −8192 to the predSample value in orderto prevent 16-bit overflow, the value of predSample may be adjusted tothe range of [−22258, 19317].

Accordingly, when BitDepth_(Y) is 8, predSample has a value of a 16-bitrange, the gradient uses 11 bits, diffMv uses 6 bits, and eventually therange of dI value is [−41471, 40824]. Accordingly, according to variousembodiments of the present disclosure, when predSample and dI are added,16-bit overflow may be generated.

According to the present disclosure, when the value of the refinedprediction sample is calculated by clipping the PROF offset (dI) valuein a predetermined range, 16-bit overflow may be prevented from beinggenerated. More specifically, predSample has a value of a 16-bit rangewhen the bit depth is 8 to 12 and predSample has a value of an 18-bitrange and 20-bit range when the bit depth is 14 and 16. Accordingly, theclipping range of dI may also be defined in consideration of the bitdepth. For example, a variable dILimit specifying the clipping range ofdI may be defined based on the bit depth, and clipping of dI mayadditionally apply to the embodiments of the present disclosure.

According to this modified example, dILimit may be set to “1<<Max(13,BitDepth_(Y)+1)”, and ((dI+1)>>1) of Equation (4) of FIG. 24 and dI ofEquation (4) of FIGS. 25, 27, 28 and 29 may be clipped in a range of[−dILimit, dILimit−1].

FIG. 33 is a view illustrating a refined PROF process of performingclipping a PROF offset according to the present disclosure.

The embodiment of FIG. 33 may be an embodiment in which clipping of dIadditionally applies to the embodiment of FIG. 28 .

Accordingly, the common portions of the embodiment of FIG. 33 and theembodiment of FIG. 28 will be omitted. According to the embodiment ofFIG. 33 , dILimit may be derived based on the bit depth. For example,according to Equation (4) of FIG. 33 , dILimit may be set to “1<<Max(13,BitDepth_(Y)+1)”. In addition, clipping of dI may be performed based ondILimit. For example, according to Equation (5) of FIG. 33 , dI may beclipped in a range of [−dILimit, dILimit−1].

According to the embodiment of FIG. 33 , in addition to the effects ofthe embodiment of FIG. 28 , 16-bit overflow may be prevented from beinggenerated when calculating the value of the refined prediction sample.

Hereinafter, a method of deriving a PROF offset dI according to anotherembodiment of the present disclosure will be described.

According to the present embodiment, it is possible to minimize rightshift operation in the gradient calculation process to improve accuracyof the PROF offset. In addition, when performing right shift operationin the dI calculation process, by adding the offset value, accuracy ofdI may further increase. In this case, the offset may be determinedbased on the right shift. For example, Equation (3) of FIG. 25 may bemodified as follows.

dI=(gradientH[x][y]*diffMv[x][y][0]+offset)>>shift1+(gradientV[x][y]*diffMv[x][y][1]+offset)>>shift1

In equation above, the offset may be set based on the first shift suchas “1<<(shift1−1)”.

Modification of Equation (3) above is not limited to application to theembodiment of FIG. 25 and is applicable to other embodiments of thepresent disclosure.

According to the present disclosure, various embodiments andmodifications of difference motion vector derivation, gradientderivation and/or PROF offset derivation are provided, and theembodiments and the modifications are combined to configure newembodiments. For example, one of the embodiments (e.g., embodiments ofFIGS. 26 and 30 to 32 ) of the difference motion vector derivation maybe combined with one of the embodiments (e.g., embodiments of FIGS. 24,25, 27 to 29 and 33 ) of the gradient derivation and/or PROF offsetderivation.

While the exemplary methods of the present disclosure described aboveare represented as a series of operations for clarity of description, itis not intended to limit the order in which the steps are performed, andthe steps may be performed simultaneously or in different order asnecessary. In order to implement the method according to the presentdisclosure, the described steps may further include other steps, mayinclude remaining steps except for some of the steps, or may includeother additional steps except for some steps.

In the present disclosure, the image encoding apparatus or the imagedecoding apparatus that performs a predetermined operation (step) mayperform an operation (step) of confirming an execution condition orsituation of the corresponding operation (step). For example, if it isdescribed that predetermined operation is performed when a predeterminedcondition is satisfied, the image encoding apparatus or the imagedecoding apparatus may perform the predetermined operation afterdetermining whether the predetermined condition is satisfied.

The various embodiments of the present disclosure are not a list of allpossible combinations and are intended to describe representativeaspects of the present disclosure, and the matters described in thevarious embodiments may be applied independently or in combination oftwo or more.

Various embodiments of the present disclosure may be implemented inhardware, firmware, software, or a combination thereof. In the case ofimplementing the present disclosure by hardware, the present disclosurecan be implemented with application specific integrated circuits(ASICs), Digital signal processors (DSPs), digital signal processingdevices (DSPDs), programmable logic devices (PLDs), field programmablegate arrays (FPGAs), general processors, controllers, microcontrollers,microprocessors, etc.

In addition, the image decoding apparatus and the image encodingapparatus, to which the embodiments of the present disclosure areapplied, may be included in a multimedia broadcasting transmission andreception device, a mobile communication terminal, a home cinema videodevice, a digital cinema video device, a surveillance camera, a videochat device, a real time communication device such as videocommunication, a mobile streaming device, a storage medium, a camcorder,a video on demand (VoD) service providing device, an OTT video (over thetop video) device, an Internet streaming service providing device, athree-dimensional (3D) video device, a video telephony video device, amedical video device, and the like, and may be used to process videosignals or data signals. For example, the OTT video devices may includea game console, a blu-ray player, an Internet access TV, a home theatersystem, a smartphone, a tablet PC, a digital video recorder (DVR), orthe like.

FIG. 34 is a view showing a content streaming system, to which anembodiment of the present disclosure is applicable.

As shown in FIG. 34 , the content streaming system, to which theembodiment of the present disclosure is applied, may largely include anencoding server, a streaming server, a web server, a media storage, auser device, and a multimedia input device.

The encoding server compresses contents input from multimedia inputdevices such as a smartphone, a camera, a camcorder, etc. into digitaldata to generate a bitstream and transmits the bitstream to thestreaming server. As another example, when the multimedia input devicessuch as smartphones, cameras, camcorders, etc. directly generate abitstream, the encoding server may be omitted.

The bitstream may be generated by an image encoding method or an imageencoding apparatus, to which the embodiment of the present disclosure isapplied, and the streaming server may temporarily store the bitstream inthe process of transmitting or receiving the bitstream.

The streaming server transmits the multimedia data to the user devicebased on a user's request through the web server, and the web serverserves as a medium for informing the user of a service. When the userrequests a desired service from the web server, the web server maydeliver it to a streaming server, and the streaming server may transmitmultimedia data to the user. In this case, the content streaming systemmay include a separate control server. In this case, the control serverserves to control a command/response between devices in the contentstreaming system.

The streaming server may receive contents from a media storage and/or anencoding server. For example, when the contents are received from theencoding server, the contents may be received in real time. In thiscase, in order to provide a smooth streaming service, the streamingserver may store the bitstream for a predetermined time.

Examples of the user device may include a mobile phone, a smartphone, alaptop computer, a digital broadcasting terminal, a personal digitalassistant (PDA), a portable multimedia player (PMP), navigation, a slatePC, tablet PCs, ultrabooks, wearable devices (e.g., smartwatches, smartglasses, head mounted displays), digital TVs, desktops computer, digitalsignage, and the like.

Each server in the content streaming system may be operated as adistributed server, in which case data received from each server may bedistributed.

The scope of the disclosure includes software or machine-executablecommands (e.g., an operating system, an application, firmware, aprogram, etc.) for enabling operations according to the methods ofvarious embodiments to be executed on an apparatus or a computer, anon-transitory computer-readable medium having such software or commandsstored thereon and executable on the apparatus or the computer.

INDUSTRIAL APPLICABILITY

The embodiments of the present disclosure may be used to encode ordecode an image.

1-15. (canceled)
 16. An image decoding method performed by an imagedecoding apparatus, the image decoding method comprising: deriving aprediction sample of a current block based on motion information of thecurrent block; determining whether prediction refinement with opticalflow (PROF) applies to the current block; deriving, based on that thePROF applies to the current block, a difference motion vector for eachsample position in the current block; deriving a gradient for eachsample position in the current block; deriving a PROF offset based onthe difference motion vector and the gradient; and deriving a refinedprediction sample for the current block based on the PROF offset,wherein the deriving the gradient comprises right-shifting a neighboringprediction sample value at each sample position in the current block bya first shift, and wherein a value of the first shift is fixed as
 6. 17.The image decoding method of claim 16, wherein the deriving thedifference motion vector comprises clipping the rounded differencemotion vector in a predetermined range, and wherein the predeterminedrange is set based on a fixed value dmvLimit derived regardless of a bitdepth of the current block.
 18. The image decoding method of claim 17,wherein the predetermined range is specified by a minimum value and amaximum value derived based on dmvLimit, and wherein an absolute valueof the minimum value and an absolute value of the maximum value are setto the same value.
 19. The image decoding method of claim 18, whereinthe minimum value is (−dmvLimit+1) and the maximum value is (dmvLimit−1.20. The image decoding method of claim 17, wherein dmvLimit is (1<<5).21. The image decoding method of claim 16, wherein a PROF offset derivedin the deriving the PROF offset is clipped in a predetermined range. 22.The image decoding method of claim 21, wherein the predetermined rangein which the PROF offset is clipped is set based on a value dILimitderived based on a bit depth of the current block.
 23. The imagedecoding method of claim 22, wherein the predetermined range in whichthe PROF offset is clipped is [−dILimit, dILimit−1].
 24. The imagedecoding method of claim 22, wherein dILimit is (1<<max(13,Bitdepth+1)).
 25. An image encoding method performed by an imageencoding apparatus, the image encoding method comprising: deriving aprediction sample of a current block based on motion information of thecurrent block; determining whether prediction refinement with opticalflow (PROF) applies to the current block; deriving, based on that thePROF applies to the current block, a difference motion vector for eachsample position in the current block; deriving a gradient for eachsample position in the current block; deriving a PROF offset based onthe difference motion vector and the gradient; and deriving a refinedprediction sample for the current block based on the PROF offset,wherein the deriving the gradient comprises right-shifting a neighboringprediction sample value at each sample position in the current block bya first shift, and wherein a value of the first shift is fixed as
 6. 26.A method of transmitting a bitstream generated by an image encodingmethod, the image encoding method comprising: deriving a predictionsample of a current block based on motion information of the currentblock; determining whether prediction refinement with optical flow(PROF) applies to the current block; deriving, based on that the PROFapplies to the current block, a difference motion vector for each sampleposition in the current block; deriving a gradient for each sampleposition in the current block; deriving a PROF offset based on thedifference motion vector and the gradient; and deriving a refinedprediction sample for the current block based on the PROF offset,wherein the deriving the gradient comprises right-shifting a neighboringprediction sample value at each sample position in the current block bya first shift, and wherein a value of the first shift is fixed as
 6. 27.A non-transitory computer-readable medium storing a bitstream generatedby the image encoding method of claim 25.